In this Azure PowerShell article, we will discuss the syntax and usage of the connect-azaccount PowerShell command with some examples of how to use this command.
The connect-azaccount is a very good PowerShell command that can help you connect to Azure with one particular authenticated account so that you can use the Azure PowerShell commands.
Below is the syntax of the connect-azaccount PowerShell command.
Connect-AzAccount -Credential <PSCredential> -Tenant <String>
Connect-AzAccount -Tenant <String> [-Subscription <String>]
Let’s discuss a few examples of how to use the Connect-AzAccount PowerShell command.
You can run the below Azure PowerShell command to connect to Azure with an Azure account.
After executing the above PowerShell command, you need to provide the Microsoft account or organizational ID credentials as shown below.
Once signed in successfully, I got the expected output as shown below.
PS C:\WINDOWS\system32> Connect-AzAccount Account SubscriptionName TenantId Environment ------- ---------------- -------- ----------- email@example.com Visual Studio Enterprise 5d9d690a-0310-474d-ae8b-42df2d549228 AzureCloud
See the same output below
You can also use the tenant and SubscriptionId with the Connect-AzAccount PowerShell command.
Connect-AzAccount -Tenant '5d9d690a-0310-474d-ae8b-42df2d549228' -SubscriptionId '1cdf4300-dee5-4518-9c9c-feaa72a5cbd1'
After executing the above PowerShell command, I got the expected output
Once you are done, you can use the Disconnect-AzAccount PowerShell command to disconnect from the Azure account that you are connected to.
You may also like following the below articles
In this Azure PowerShell article, we discussed the syntax and usage of the connect-azaccount PowerShell command with examples of how to use this command. Thanks for reading this article !!!