---
title: "Azure Authentication Made Easy with PowerShell Connect-AzAccount"
description: "Simplify Azure authentication with PowerShell by learning the various ways to authenticate using the Connect-AzAccount cmdlet instead of its two aliases."
canonical: "https://adamtheautomator.com/connect-azaccount/"
---

# Azure Authentication Made Easy with PowerShell Connect-AzAccount

> Simplify Azure authentication with PowerShell by learning the various ways to authenticate using the Connect-AzAccount cmdlet instead of its two aliases.

Source: https://adamtheautomator.com/connect-azaccount/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![Azure Authentication Made Easy with PowerShell Connect-AzAccount](https://adamtheautomator.com/wp-content/uploads/2019/06/5d238ae5c824b514689ea520.jpg)

# Azure Authentication Made Easy with PowerShell Connect-AzAccount

[![](https://secure.gravatar.com/avatar/d0b9d42e21e5622713f8b693aa5c0f9244d5f7dd200ed29b8398f52dee5de337?s=192&d=mm&r=g)Adam Bertram](https://adamtheautomator.com/author/adam-bertram/)15 June 20192 min. read

Categories: [Cloud](/category/cloud/)

Tags:[Microsoft Azure](/tag/microsoft-azure/)[PowerShell](/tag/powershell/)

Table of Contents

*   [When in Doubt, use Connect-AzAccount](#when-in-doubt-use-connect-azaccount)
*   [Authenticating with Connect-AzAccount](#authenticating-with-connect-azaccount)
*   [Signing in Interactively](#signing-in-interactively)
*   [Signing in with a Service Principal](#signing-in-with-a-service-principal)
*   [Signing in with a Managed Service Identity](#signing-in-with-a-managed-service-identity)
*   [Signing in as a Cloud Solution Provider (CSP)](#signing-in-as-a-cloud-solution-provider-csp-)
*   [Signing into a Non-Public Cloud](#signing-into-a-non-public-cloud)
*   [Wrap Up](#wrap-up)

`Login-AzAccount`, `Add-AzAccount` or Connect-AzAccount there appears to be a lot of different ways to authenticate to an Azure subscription if you’re using PowerShell!

## When in Doubt, use Connect-AzAccount

When I first started working with Azure in PowerShell, I was severely confused. I’d find some articles talking about using `Login-AzAccount` while others mentioned using `Add-AzAccount` but few mentioning `Connect-AzAccount`. Which one do I use in what kind of circumstances? What is going on here?!?

I’m here to tell you if you’re struggling with the same problem I was, the solution is a lot easier than you might expect. Although there may seem to be three different commands to authenticate to Azure with PowerShell, in reality, there’s only one. It is `Connect-AzAccount`. Both `Login-AzAccount` and `Add-AzAccount` are only aliases to the `Connect` command.

I’m here to tell you to just use Connect-AzAccount and you’ll be good as gold. I don’t recommend using aliases, if possible just because it makes things confusing as you can vouch for. With people using different ways to accomplish the same task, it’s hard to figure out what exactly is happening.

Feel free to verify me by using `Get-Alias`.

![Get-Alias -Name \*AzAccount\* | Select Name,ReferencedCommand](https://adamtheautomator.com/content/images/2019/07/connect-azaccount--1-.png)

Get-Alias -Name \*AzAccount\* | Select Name,ReferencedCommand

## Authenticating with Connect-AzAccount

There are [lots of ways](https://docs.microsoft.com/en-us/powershell/azure/authenticate-azureps?view=azps-7.1.0&viewFallbackFrom=azurermps-6.11.0) to authenticate to [Azure](https://adamtheautomator.com/azure-free/) using `Connect-AzAccount`. The method to do so depends on what resources you’re authenticating to. For example, there are roughly five different ways to authenticate to Azure.

*   Interactively
*   Using a [service principal](https://adamtheautomator.com/azure-service-principal/ "service principal")
*   Using an Azure Managed Service Identity
*   As a [Cloud Solution Provider (CSP)](https://azure.microsoft.com/en-us/offers/ms-azr-0145p/)
*   Into a non-public cloud

## Signing in Interactively

The most common way people just starting to work with Azure will connect interactively. This means, they will run `Connect-AzAccount` and will be prompted for credentials.

This method works if you have a [Microsoft](https://adamtheautomator.com/tag/microsoft-azure/) or organizational Office 365 account and don’t need to automate the task.

## Signing in with a Service Principal

You can also use a service principal to authenticate. This along with the managed service identity is the way to go if you need to authenticate in an automated script. However, this requires creating an Azure Active Directory application along with the service principal itself which is a little set up ahead of time. For a full overview of how to get that set up, you can check out this TechSnips video entitled [How To Create And Authenticate To Azure With A Service Principal Using PowerShell](https://techsnips.io/snips/how-to-create-and-authenticate-to-azure-with-a-service-principal-using-powershell/). It covers all of the steps you need to get one set up.

Authenticating with a service principal will force you to use the `Connect-AzAccount` `Credential` and `ServicePrincipal` parameters.

The `ServicePrincipal` parameter indicates that this account authenticates by providing service principal credentials. The `Credential` parameter specifies a PSCredential object.

## Signing in with a Managed Service Identity

Another way is used [managed service identities](https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/how-to-use-vm-token) which, to be honest, I have never done before. I’ve provided a link in this section to get an overview of that. Some of the commands used with `Connect-AzAccount` when authenticating with managed service identities are:

*   `ManagedServiceHostName` – Host name for managed service login
*   `ManagedServicePort` – Port number for managed service login
*   `ManagedServiceSecret` – Secret, used for some kinds of managed service login.

## Signing in as a Cloud Solution Provider (CSP)

If your company is a Microsoft partner and uses Azure services to directly provide resources to your customers, you may use `Connect-AzAccount` and use the `TenantId` parameter. This is required to specify a different Azure AD tenant.

## Signing into a Non-Public Cloud

Finally, although not too common is the ability to authenticate to a non-public cloud like a government or country cloud. These clouds are represented by an Azure environment using the Environment parameter on `Connect-AzAccount`. If you don’t know the environment name, you can always use the `Get-AzEnvironment` command.

![Get-AzEnvironment | Select Name](https://adamtheautomator.com/content/images/2019/07/azure-clouds--1-.png)

Get-AzEnvironment | Select Name

## Wrap Up

As you can see, there are a lot of different ways to authenticate to Azure because Azure is a big service! Using `Connect-AzAccount` with PowerShell, you’ll able to provide all of the necessary parameters Azure needs to interactively or non-interactively process your credentials and allow you to get going!

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Fconnect-azaccount%2F&text=Azure%20Authentication%20Made%20Easy%20with%20PowerShell%20Connect-AzAccount)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Fconnect-azaccount%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Fconnect-azaccount%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2019/08/microsoft-graph.png)

### [Mastering PowerShell Graph API: Easy-to-Follow Insights](/powershell-graph-api/)

Master the PowerShell Graph API with our concise guide. Learn to access, read, and manage data effortlessly, enhancing your API skills quickly and efficiently.

![](https://adamtheautomator.com/wp-content/uploads/2020/02/braydon-anderson-wOHH-NUTvVc-unsplash-scaled.jpg)

### [Deploy Azure DSC Configurations with ARM Templates](/azure-dsc-2/)

Master the deployment of Azure DSC configurations to Azure VMs using ARM templates. Boost your cloud management skills and IT expertise.

![](https://adamtheautomator.com/wp-content/uploads/2019/12/network-2402637_1280.jpg)

### [Optimize Azure Scale Sets Management with PowerShell](/azure-powershell-scale-set/)

Master Azure Scale Sets management using PowerShell. Learn to create, configure, and automate VM scale sets for improved cloud infrastructure.

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
