iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
💻

Creating Azure AD Applications from the Command Line

に公開

Introduction

Until now, I have always created Azure AD applications via the Azure Portal, but since it is problematic if they are not codified during deployment, I have summarized the methods for doing so. There are several ways to achieve this, and I had some trouble, so I am documenting them here.

Comparison of modules

AzureAD module

You can use New-AzureADApplication to create applications.

https://docs.microsoft.com/en-us/powershell/module/azuread/new-azureadapplication?WT.mc_id=M365-MVP-5002941

After trying it out, I encountered the following issues:

  • It is not compatible with PowerShell Core.
  • The parameters are extremely complex.

Az module

You can use New-AzADApplication to create applications.

https://docs.microsoft.com/en-us/powershell/module/az.resources/new-azadapplication?WT.mc_id=M365-MVP-5002941

After trying it out, I encountered the following issues:

  • There are few parameters that can be configured.
    • For example, you cannot specify oauth2AllowImplicitFlow.
  • You cannot omit IdentifierUris.

Azure CLI

You can use az ad app create to create applications.

https://docs.microsoft.com/en-us/cli/azure/ad/app?WT.mc_id=M365-MVP-5002941#az_ad_app_create

After trying it out, I encountered the following issues:

  • The return value is difficult to handle.
    • This becomes a problem when you need to use the Application ID to perform subsequent processes after creating the application.
  • You cannot create applications with the same name.
    • Information for an existing application with the same name is automatically overwritten.

Microsoft.Graph module

You can use New-MgApplication to create applications.

https://github.com/microsoftgraph/msgraph-sdk-powershell

After trying it out, I encountered the following issues:

  • The parameter format is slightly different from the manifest definition.

Conclusion

For now, the Microsoft.Graph module seems to be the best choice.

Discussion