Azure CLI - Troubleshooting in Azure with PowerShell
Mathias Weber
Data Architect and Author of the Book "Other People's Software Endeavours"
There are two ways you can interact with the Azure platform:
For smaller deployments it can be more convenient to the human user to interact through the Azure portal. However, for larger deployments this approach does not seem to be feasible. Imagine the amount of clicking you would need to deploy hundreds of resources to the Azure platform. Additionally this "clicking approach" might also introduce lots of mistakes. The better approach in this case would be to create a batch script with a looping logic.
Problem
When dealing with the migration of resources from one subscription to another subscription I performed the migration in the Azure portal due to the small size of the deployment. For one of the migrated resources I needed to adjust the settings, which pointed to a storage account. The old storage account remained in the source subscription. That's why I needed to change the settings to point to a new storage account in the target subscription. Theses actions were performed by me in the Azure portal (in the GUI of the Azure platform). However, when trying to look at a report, I received the error, that I do not have access to the old storage account. This contradicted the settings being displayed to me in the Azure portal.
Troubleshooting
To check the settings in a different way I opened up a Cloud Shell session and checked the resource settings using PowerShell. Not because I am a big fan of PowerShell, but because the available command-lets for Bash were not sufficient enough to view the resource settings for this specific resource. Lo and behold, the settings displayed in the Cloud shell terminal differed from the ones displayed in the portal. I adjusted the settings using a PowerShell command-let and the bug was gone.
领英推荐
Exemplary PowerShell Cmdlet
Let's have a quick look at an example cmdlet. The below PowerShell cmdlet outputs the name, type, location and state of an Azure logic app I previously created in the Azure portal.
Get-AzLogicApp -Name "Amtsblatt-Workflow" | Format-Table -Property Name, Type, Location, State
I ran the cmdlet in a Cloud Shell session which I opened in the Azure portal. All of that was done within my browser and I did not have to install anything. The cloud is the future.