Set-Azcontext: Please Provide a Valid Tenant or a Valid Subscription

I am trying to swap over to a different subscription within my Azure Account. The subscription is correct and the command itself seems to be correct but I am getting the error in the screenshot. Any suggestions..?

3

3 Answers

I avoid issues like that by listing all of your subscriptions you have access to, filter those for the one you want, and set that as your active context.

Get-AzContext -ListAvailable | Where{$_.Name -match 'MySub1'} | Set-AzContext 

You just need to fill in the name of the subscription or something. You can also run Get-AzContext -ListAvailable to see what subscriptions are available to you.

Make sure you logged in with the correct AAD tenant which the subscription locates in, just pass the tenant id to the command.

Set-AzContext -Subscription <subscription-id> -Tenant <tenant-id>

After receiving this error I ran

Login-AzureRmAccount

Logged in to the login screen that appeared and it started working

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Chloe Bennett

Chloe Bennett

Culture, Media & Entertainment Columnist

Chloe Bennett explores the intersection of pop culture, streaming entertainment, digital trends, and contemporary lifestyle. Her weekly commentary reaches thousands of culture enthusiasts.

Share this article
Twitter Facebook Pinterest