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.
Best Answer
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:
Then you can get the subscription through the PowerShell command:
It would show the subscriptions you have. Like this:
And select the subscription through the PowerShell command:
Then you can create the VM as you do before.