Skip to content
Azure Lessons
Azure Lessons
  • Home
  • AWS
  • Azure
    • Azure Virtual Machine
    • Azure Active Directory
    • Azure CLI
    • Azure CLI Commands List
    • Azure Cognitive Services
    • Azure Cosmos DB
    • Azure DevOps
    • Azure Functions
    • Azure PowerShell Commands
    • Azure Sentinel
    • Azure SQL
    • Azure Storage
    • Azure Synapse
  • Blogs
  • FREE EBOOK

Az login service principal

March 12, 2024October 31, 2023 by Rajkishore

Log in to Azure using the az login cmdlet with the service principal. Once you execute the az login cmdlet, it will prompt you to provide the Azure user name and password or Azure account credentials.

Table of Contents

  • syntax of az login
  • Examples of AZ login
    • Example-1
    • Example-2

syntax of az login

Below is the syntax of the az login command.

az login
az login [--allow-no-subscriptions] [--identity] [--password] [--service-principal]
         [--tenant] [--use-cert-sn-issuer] [--use-device-code] [--username]

Examples of AZ login

Example-1

After executing the below command, It prompted me to enter the credentials and after entering the credentials and On successful login, it showed me the below pop-up with the successful log in message “You have logged into Microsoft Azure!”. Check out the below screen shot for your reference.

az login
az login

Example-2

You can execute the script below to log in to Azure using the service principal.

$appID="ghj56789-067e-7890-h9k1-jdd6kk11bf1646"
$password="xyz"
$tenant="xxxxxxx"
az login --service-principal -u $appID --password $password --tenant $tenant

You may also like following the articles below

  • Az login –identity
  • az account show
  • az account set subscription

Conclusion

In this Azure article, we discussed the syntax and usage of the az login command with examples. Thanks for reading this article !!!

Microsoft Azure
Rajkishore

I am Rajkishore, and I am a Microsoft Certified IT Consultant. I have over 14 years of experience in Microsoft Azure and AWS, with good experience in Azure Functions, Storage, Virtual Machines, 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.

az account set subscription
New-AzADSpCredential
Subscribe To Our YouTube Channel Subscribe to AzureLessons YouTube Channel

Recent Posts

  • Azure Front Door vs Application Gateway
  • Azure Container Apps
  • How to Check Azure App Service Logs
  • Azure Advisor vs Azure Monitor
  • How to Get Azure Function URL
  • About Us
  • Contact Us
  • Privacy Policy
  • Sitemap
© 2026 Azure Lessons