Creating the application Client ID and Client Secret from Microsoft Azure new portal - Part 1

This article explains how to generate Client ID and Client Secret from the Microsoft Azure new portal. In Part 2(Creating  the Application Client ID and Client Secret from Microsoft old portal), we will cover how to generate Client ID and Client Secret from the Microsoft Azure old portal. There is a difference in UI for generating the IDs when both are compared.

Login to the new Azure Active Directory portal

If you already have a user account in your Azure Active Directory tenant, or if you signed in to the Azure portal with a Microsoft account and have never created an app in your directory before, you need to do that now.

Obtain a Client Id and Client Secret for a Microsoft Azure Active Directory

  1. Sign in to the Azure portal.

  • On the top bar, click on your account and under the Directory list, choose the Active Directory tenant where you wish to register your application.

  • Click on More Services on the left hand side, and choose Azure Active Directory.1

  • Click on App registrations and choose Add.2

  • Click on Add to create the application.3

    • Enter a friendly name (can be any name) for the application, for example 'AzureADDriver1' and select 'Web Application and/or Web API' as the Application Type. For the sign-on URL, enter the base URL for the sample, which can be “http://AzureADDriver1” Sign-on URL: your application URL (completely arbitrary) then click on the Create button, as shown below.

  • While still in the Azure portal, choose your application, click on Settings. Find the Client ID value and copy it to the clipboard.The Client ID here is the Application ID from the Azure application as shown in the below figure.

  • Now, to obtain the Client Secret / Key Click on the Keys option appearing on the right hand side, which looks as given below.7

  • The key will be displayed when these settings are saved and compulsory, copy the key to the clipboard, once you leave the page the key will not be visible.8

  • Client ID and the Key generated by Microsoft Azure from the App is the Client ID and Client Secret

    • For Example: The Client ID and Client Secret looks like:

      • Client ID: 53ba6f2b-6d52-4f5c-8ae0-7adc20808854

    • Client Secret: NMubGVcDqkwwGnCs6fa01tqlkTisfUd4pBBYgcxxx=

Now this Client ID and Client Secret will be used for your driver configurations or any other rest clients.


Providing rights to your Client ID / application via PowerShell

Open PowerShell as Administrator and run the following commands in the order mentioned below:

  1. Connect to the Office 365 Exchange Online service using the following command and provide your exchange login credentials:

    Note: If you don't get any error messages assume login is successful.

  • Run the following commands in Power Shell.Running the command below will list all the Client IDs in the Azure application. <AppPrincipalID> should be replaced with your Client ID:
    General Syntax: Get-MsolServicePrincipal | ft DisplayName, <AppPrincipalId> -AutoSize

    For Example: Get-MsolServicePrincipal | ft DisplayName, 8b523s82-09d3-464e-af4f-28c82923e0m1 -AutoSize
    General Syntax: $ClientIdWebApp = '<AppPrincipalId>'

    For Example: $ClientIdWebApp = '8b523s82-09d3-464e-af4f-28c82923e0m1'

  • Run the following command to assign the "Company Administrator" rights to your application (Client ID), copy the commands below:
    $webApp = Get-MsolServicePrincipal –AppPrincipalId $ClientIdWebApp Add-MsolRoleMember -RoleName "Company Administrator" -RoleMemberType ServicePrincipal -RoleMemberObjectId $webApp.ObjectID

Note: The Company Administrator role will give you complete rights to your application.

For reference, see the screenshot below of a successful rights assignment for an application.


Hope this helps.

Information Source: Microsoft Azure Guide.



How To-Best Practice
Comment List