If you want to execute a PowerShell scripts that does something in Azure, you might want to start your script with making sure the right subscription is chosen.
I had a task to automate creation of Azure resources required for an application that we were building. I used a combination of ARM Templates and Azure PowerShell to create the resources, but I had to make sure that whoever would run the script had an option of choosing whichever subscription they wanted. This way it was easy to package up the application, and just have single script that will set up required cloud resources.
If you are just starting with Azure, you probably have only one tenant and only one Pay-As-You-Go subscription. But if you are a regular Azure user, you might have your MSDN subscription, your company’s subscription, plus any other subscriptions attached to one or more of your customers.
While creating this script I found an interesting behavior in the
Connect-AzAccount step. You might not be offered subscriptions from the account you signed in with. This script fixes that, and details are linked in commented out code.