Azure CLI Commands by Patrik

Azure Login CLI Commands

Sign in interactively

The Azure CLI's default authentication method for logins uses a web browser and access token to sign in.

az login

If the CLI can open your default browser, it will do so and load an Azure sign-in page. Otherwise, open a browser page at https://aka.ms/devicelogin and enter the authorization code displayed in your terminal. Sign in with your account credentials in the browser.

If no web browser is available or the web browser fails to open, use device code flow with az login --use-device-code.

Sign in with a different tenant

You can select a tenant to sign in under with the --tenant argument. The value of this argument can either be an .onmicrosoft.com domain or the Azure object ID for the tenant. Both interactive and command-line sign in methods work with --tenant.

az login --tenant {tenant}

Additional details can be found at Sign in with Azure CLI — Login and Authentication | Microsoft Docs

Log into Azure using a Service Principal

az login --service-principal --username {SPN_CLIENT_ID} --password {SPN_CLIENT_SECRET} --tenant {SPN_TENANT_ID}

Comments