DEV Community

Cover image for How to register an application in Azure AD using Azure CLI
Eli H. Schei
Eli H. Schei

Posted on • Originally published at elischei.com

How to register an application in Azure AD using Azure CLI

If you are working as a M365 developer you probably have had to register an application i Azure AD at some point. In this blogpost I will show you how you can do so using Azure CLI.

Prerequesites: You need to download and install Azure CLI.

Sign in to your tenant

When you have installed the Azure CLI you can sign in to your tenant. If you are on a dev-tenant or you don’t have a subscription to your account you should also add the “Allow-no-subscription” flag like shown below.

az login


az login --allow-no-subscriptions
Enter fullscreen mode Exit fullscreen mode

Add the app

When you have successfully signed in you can register a new app with a simple line.

az ad app create --display-name MyApp01 --available-to-other-tenants false
Enter fullscreen mode Exit fullscreen mode

This will return a JSON object with the app information. I have shortened it down a bit in the example below.

{
  "acceptMappedClaims": null,
  "addIns": [],
  "allowGuestsSignIn": null,
  "allowPassthroughUsers": null,
  "appId": "ee26ecb3-977f-4520-ac21-be9eec424538",
 ...
  },
  ...
  ],
  "oauth2RequirePostResponse": false,
  "objectId": "301fc40c-a293-4509-8178-9d1b0fd76444",
  ...
  },
  ...
}
Enter fullscreen mode Exit fullscreen mode

Two values that you should notice are the “appId, and the “objectId”. These values are often used when connecting to your registered app remotely. You can find the same information in the azure portal.
Screenshot showing the app registration in Azure AD portal


Resources


Did you find this article usefull? Follow me on twitter to be notified when I publish something new!

Also, if you have any feedback or questions, please let me know in the comments below. :)

Thank you for reading!

/Eli

Latest comments (0)