Azure PowerShell - No default subscription has been designated

I came across this error after installing Azure PowerShell via WebPI and I launched Azure PowerShell using Administrator.

“Get-AzureRemoteAppCollectionUsageDetails: No default subscription has been designated”

Quiet strange as I had logged in using my account details and authenticated successfully, imported Azure Module by using the command “Import-Module Azure”.

I was trying to explore the cmdlets in Azure PowerShell and build a VM from the set of commands, to take a next step I had to get my Subscription and Set it before I can view or gather any information on my Subscription and view my setup I had in Azure Portal.

Detailed error information from Azure PowerShell:
Get-AzureRemoteAppCollectionUsageDetails : No default subscription has been designated. Use Select-AzureSubscription
-Default <subscriptionName> to set the default subscription.
At line:1 char:1
+ Get-AzureRemoteAppCollectionUsageDetails
    + CategoryInfo          : CloseError: (:) [Get-AzureRemoteAppCollectionUsageDetails], ApplicationException
    + FullyQualifiedErrorId : Microsoft.WindowsAzure.Management.RemoteApp.Cmdlets.GetAzureRemoteAppCollectionUsageDetails

I explored all the cmdlets and came across one to Add an Azure Account, I tried to read more information on this from Get-Help Add-AzureAccount command and the information was very useful.

Desciption

The Add-AzureAccount cmdlet makes your Azure account and its subscriptions available in Windows PowerShell. It's like logging into your Azure account in Windows PowerShell. To log out of the account, use the Remove-AzureAccount cmdlet.
Add-AzureAccount downloads information about your Azure account and saves it in a subscription data file in your roaming user profile. It also gets an access token that allows Windows PowerShell to access your Azure account on your behalf. When the command completes, you can manage your Azure account in Windows PowerShell. There are two different ways to make your Azure account available to Windows PowerShell. You can use the Add-AzureAccount cmdlet, which uses Azure Active Directory (Azure AD) authentication access tokens.

Results

Once I executed the command Add-AzureAccount, it prompted me to login to the portal and successfully retrieved my Subscription details and added in my current session.







Following adding my Subscription I was able to run all the commands to retrieve my Subscription details and execute Set commands to prepare a Virtual Machine.

I had configured a Virtual Network Gateway and Remote App Collection, I was able to retrieve all of them and modify accordingly. 


Hope this helps anyone having issues with Azure Power Shell to start with.


Enjoy PowerShelling :)

Comments

Popular posts from this blog

Windows 11 22H2 RDP disconnects and freezes randomly

Certification - 70-533

Windows 2019 Server Change TimeZone error "Unable to continue" You Do not have permissions to perform this task.