Why can't AzureRmAks find SSH key when deploying new Kubernetes cluster? - azure

Last night I used PowerShell to deploy a Kubernetes cluster on AKS with something like this:
New-AzureRmAks -ResourceGroupName "my-rg" -Name "my-aks-cluster" -KubernetesVersion "1.16.13" -NodeCount 2 -NodeVmSize "Standard_DS2_V2" -Verbose
This worked fine. Today, however, I tried this same thing in a different subscription, but keep getting the following error:
VERBOSE: Cluster does not exist.
VERBOSE: Cluster is new.
VERBOSE: Performing the operation "Creating a managed Kubernetes cluster." on target "my-aks-cluster in my-rg".
VERBOSE: Preparing for deployment of your managed Kubernetes cluster.
VERBOSE: Using location eastus from the resource group my-rg.
VERBOSE: Using DNS name prefix my-aks-cluster-my-rg-dcdf2a.
VERBOSE: Fetching SSH public key from file C:\Users\myuser\.ssh\id_rsa.pub
New-AzureRmAks : The given key was not present in the dictionary.
At line:1 char:1
+ New-AzureRmAks -ResourceGroupName "my-reg" -Name "my-aks-cluster" -Kube ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [New-AzureRmAks], KeyNotFoundException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Aks.NewAzureRmAks
I'm confused because:
This same command worked earlier
I have same admin rights to new subscription as to the one previously used
The path to the key is valid
The key, id_rsa.pub, is at the path listed
Anyone have an idea what is going on here? Any tips are appreciated.

I can reproduce this issue with the same user account when only changing to a new subscription in another directory.
To fix it, you can delete all files but leave TokenCache.dat file in the .Azure folder of the path
C:\Users\myuser\.Azure
Then re-connect the subscription.
Edit
In this case, deleting the file acsServicePrincipal under the local .azure directory is to fix this issue.

Related

trouble deploying from azure devops because of service quota limits

I have been battling with an issue for day now, Anytime i try to deploy from azure pipeline, i get this error:
Failed to create an app in Azure Active Directory. Error: The directory object quota limit for the Principal has been exceeded. Please ask your administrator to increase the quota limit or delete objects to reduce the used quota.
came across a resource on stackoverflow from:
Can't create new Service Principals in Azure despite being under quota
and followed the guide in the resource, but still didnt work.
Get-AzureADDeletedApplication -all 1 | ForEach-Object { Remove-AzureADdeletedApplication -ObjectId $_.ObjectId }
this is the error i get running the above command :
Get-AzureADDeletedApplication: The term 'Get-AzureADDeletedApplication' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Please note the command was run in powershell knowing it is a powershell command. Also, if there is a cli command to use to clear this, that would be really appreciated.
I would be gad if anyone can help cause this is frustrating and i am behind time.
Thanks guys
I tried in my environment and got similar error when I run the same commands:
Get-AzureADDeletedApplication
This error occurs due to that you have not install azureAD or install azureADPreview
Install the module
install-module AzureAD or install-module AzureADPreview
Connect with your azure active directory by following commands with your credentials.
Connect-AzureAD
When I connected with azure ad i can list all the DeletedazureADApplication.
First I tried to delete the particular AD application it is successfully deleted.
Remove-AzureADdeletedApplication -ObjectId 00000000-0000-0000-0000-000000000000
Later I tried to delete all the application with following commands and got successfully deleted the azureADdeletedapplication.
Get-AzureADDeletedApplication -all 1 | ForEach-Object { Remove-AzureADdeletedApplication -ObjectId $_.ObjectId }
Reference:
https://learn.microsoft.com/en-us/powershell/module/azuread/get-azureaddeletedapplication?view=azureadps-2.0

Publish-AzWebApp throwing an aggregate exception, need to understand why/ how to debug

I am currently building a powershell script which creates 2 web app services in azure and then publishes the apps. The first app, which is a react app, publishes. The backend, built using node.js, throws an aggregate exception. I dont't know what to do with this or how to debug it.
I have tried isolating the second publish command to see if anything is interfering with it, but it still throws the same error.
Publish-AzWebApp -ResourceGroupName $resourcegroup -Name frontend$webappname -ArchivePath "C:\Users\Charles\Desktop\Timesheet App\Discover\DiscoverBuild.zip"
Publish-AzWebApp -ResourceGroupName $linuxresourcegroup -Name backend$webappname -ArchivePath "C:\Users\Charles\Desktop\Timesheet App\Discover\SNAP.zip"
Expect the app to publish ok, instead receive the following error:
Publish-AzWebApp : One or more errors occurred.
At C:\Users\Charles\Desktop\Timesheet App\Discover\deployScript.ps1:127 char:1
+ Publish-AzWebApp -ResourceGroupName $linuxresourcegroup -Name backend ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Publish-AzWebApp], AggregateException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.WebApps.Cmdlets.WebApps.PublishAzureWebAppCmdlet
Problem was caused by a setting being wrong when the app service was created. When the app service is created I needed to set "clientAffinityEnabled": true. I did this in an arm template but you can probably change the settings in antoher way.
You could check the application log to debug.
Navigate to the App Service logs in your web app in the portal -> select the Application Logging with File System.
Then run your command again, after a while, navigate to Log stream -> check the log.

Unable to create client VM that access Azure Sql Managed Instance due to core quota limit

I have create Azure SQL Managed Instance and I want to create client VM that will be used to access the instance. I have copied the configuration script from the Azure portal:
When I execute this script via PowerShell, I'm getting the following error:
New-AzureRmResourceGroupDeployment : 5:06:13 PM - Error: Code=InvalidTemplateDeployment; Message=The template deployment 'azuredeploy' is not valid according to the
validation procedure. The tracking id is '8bc76e8d-3070-44a3-bc43-58bbeeac20d8'. See inner errors for details. Please see https://aka.ms/arm-deploy for usage details.
At line:179 char:1
+ New-AzureRmResourceGroupDeployment -ResourceGroupName $resourceGroupN ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-AzureRmResourceGroupDeployment], Exception
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupDeploymentCmdlet
New-AzureRmResourceGroupDeployment : 5:06:14 PM - Error: Code=QuotaExceeded; Message=Operation results in exceeding quota limits of Core. Maximum allowed: 100, Current
in use: 100, Additional requested: 2. Please read more about quota increase at http://aka.ms/corequotaincrease.
At line:179 char:1
+ New-AzureRmResourceGroupDeployment -ResourceGroupName $resourceGroupN ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-AzureRmResourceGroupDeployment], Exception
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupDeploymentCmdlet
If these some explanation why this error happens and hot to see what is the current quota?
The first error shows that you have InvalidTemplateDeployment. You could execute this script with Invoke-Command here to run commands on local and remote computers. Once you copy this script to your power shell command line, you would need to set the password for VM and execute the script. Once you execute the script, you will see that it deployed your VM. You can get more details from this step by step.
For the second error. The quota is for each individual region, not for the entire subscription. You can use the Get-AzureRmVMUsage -Location "South Central US" command to find virtual machine quotas with a specific location. You can get more reference about resolving errors for resource quotas.

The term 'Set-AzureRmVMPlan' is not recognized as the name of a cmdlet

I am trying to create a VM on Azure using powershell script in Azure Automation. This VM is to be created from marketplace. So I need to use cmdlet 'Set-AzureRmVMPlan' in my script.
$vm = New-AzureRmVMConfig -VMName $inVMName -VMSize $vmSize
Set-AzureRmVMPlan -VM $vm -Publisher "kali-linux" -Product
"kali-linux" -Name "kali"
This script works fine when I run it from Powershell ISE however when I put this command in Azure Automation Runbook then Azure doesn't recognize this command. I get below error,
Set-AzureRmVMPlan : The term 'Set-AzureRmVMPlan' is not recognized as
the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was
included, verify that the path is correct and try
again.
At restore-vhd-backups:8 char:8
CategoryInfo : ObjectNotFound: (Set-AzureRmVMPlan:String) [], CommandNotFoundException
FullyQualifiedErrorId : CommandNotFoundException
So I further investigate and found that this command is not available in cmdlet list at page "Edit PowerShell Runbook" (see below image)
I also got to know that this cmdlet was added in Azure Powershell last year from below link
How to include "Plan information" when creating ARM VM from a captured image using Powershell?
Can someone help me on this?
So what is happening here, Azure Automation uses the old version of the Module, you have to go to Azure Automation Blade > Assets > Modules > Browse Gallery and reimport AzureRM.Profile and AzureRM.Compute.

Publish-AzureServiceProject command failed for node.js application

I am following this tutorial to deploy node.js application from my machine to windows azure:
https://www.windowsazure.com/en-us/develop/nodejs/tutorials/getting-started/
my command is as below:
Publish-AzureServiceProject -ServiceName socketlistener -Location "East US" -Launch
but I am getting the following error
Publishing to Windows Azure. This may take several minutes...
1:32:36 PM - Preparing runtime deployment for service 'socketlistener'
1:32:38 PM - Preparing deployment for socketlistener with Subscription ID: ***...
1:32:40 PM - Verifying storage account 'socketlistener'...
Publish-AzureService : Path for package doesn't exist in D:\dev\node\socketlistener\cloud_package.cspkg.
At line:1 char:21
Publish-AzureService <<<<
CategoryInfo : CloseError: (:) [Publish-AzureService], FileNotFoundException
What I am suspecting is that there is some issue with your application configuration (Service Definition or Service Configuration) which is causing problem in package creation. The error message also suggests the same problem. Based on Publish-AzureServiceProject command execution the next step is to create the package after verifying the storage account. And after the package creation, the next step is to connect service endpoint which you can verify in the same link above you are following in tutorial.
To verify that there is no issue with your machine or connection to Windows Azure application, try creating a new Node.js application, add new web/worker role and do not make any changes in configuration then try deploying. This will verify if there is any issue with your machine configuration (if any) or other issue:
New-AzureServiceProject your_node_project
Add-AzureNodeWebRole
Publish-AzureServiceProject -ServiceName socketlistener -Location "East US" -Launch

Resources