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.
Table of Contents
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.
Syntax of connect-azaccount
Below is the syntax of the connect-azaccount PowerShell command.
-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 PowerShell command, you must 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 execute the below Azure PowerShell command to connect to Azure with Managed Service Identity.
Set-AzContext -Subscription "Visual Studio Enterprise"
After executing the above PowerShell command, I got the output as expected. You can check out the screenshot 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 articles below
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 !!!
I am Rajkishore, and I have over 14 years of experience in Microsoft Azure and AWS, with good experience in Azure Functions, Storage, Virtual Machine, Logic Apps, PowerShell Commands, CLI Commands, Machine Learning, AI, Azure Cognitive Services, DevOps, etc. Not only that, I do have good real-time experience in designing and developing cloud-native data integrations on Azure or AWS, etc. I hope you will learn from these practical Azure tutorials. Read more.