I just followed the commands in the Azure create a Windows VM training. After successfully creating the new VM the powershell timed out. When I tried to continue the training I got this message:

Get-AzVMImagePublisher : No subscription found in the context. Please ensure that the credentials you provided are authorized to access an Azure subscription, then run Connect-AzAccount to login. At line:1 char:1 + Get-AzVMImagePublisher -Location "WestUS" + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : CloseError: (:) [Get-AzVMImagePublisher], ApplicationException + FullyQualifiedErrorId : Microsoft.Azure.Commands.Compute.GetAzureVMImagePublisherCommand

and it keeps happening.


Before creating the VM, there should be a subscription in the tenant that you log in with your account. In PowerShell, you can login first like this:


It shows like this after you login with your Azure account:

enter image description here

Then you can get the subscription through the PowerShell command:


It would show the subscriptions you have. Like this:

enter image description here

And select the subscription through the PowerShell command:

Select-AzSubscription -Subscription subscription_Id

Then you can create the VM as you do before.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.