Wednesday, May 5, 2021

How to suppress warning "TenantId ... contains more than one active subscription. First one will be selected for further use" when use Connect-AzAccount

When you use Connect-AzAccount cmdlet from Az.Accounts module and there are several subscriptions in your tenant it will show the following warning:


"TenantId ... contains more than one active subscription. First one will be selected for further use. To select another subscription, use Set-AzContext"

If you want to handle this situation and give user possibility to explicitly select needed subscription then this warning may not be needed (as it may confuse end users). In order to suppress it use "-WarningAction Ignore" parameter:

Connect-AzAccount -WarningAction Ignore

In this case warning won't be shown:

You may use this technique for suppressing warning from other cmdlets too.

1 comment:

  1. Hi Alexey,

    Thank you for sharing this! This tip helped me suppress errors for an Azure Runbook I created to stop Azure VMs. The service principal of the Azure Automation Account has Contributor permissions on 2 different subscriptions, so this error you noted kept popping up. It was annoying. Thanks! -Josh

    ReplyDelete