Use Azure CLI to create an Azure AD app and configure it to access Media Services API


No new features or functionality are being added to Media Services v2.
Check out the latest version, Media Services v3. Also, see migration guidance from v2 to v3

This topic shows you how to use the Azure CLI to create an Azure Active Directory (Azure AD) application and service principal to access Azure Media Services resources.


Use the Azure Cloud Shell

  1. Sign in to the Azure portal.

  2. Launch the Cloud Shell from the upper navigation pane of the portal.

    Cloud Shell

For more information, see Overview of Azure Cloud Shell.

Create an Azure AD app and configure access to the media account with Azure CLI

az login
az ad sp create-for-rbac --name <appName> 
az role assignment create --assignee < user/app id> --role Contributor --scope <subscription/subscription id>

For example:

az role assignment create --assignee a3e068fa-f739-44e5-ba4d-ad57866e25a1 --role Contributor --scope /subscriptions/0b65e280-7917-4874-9fed-1307f2615ea2/resourceGroups/Default-AzureBatch-SouthCentralUS/providers/

In this example, the scope is the full resource path for the media services account. However, the scope can be at any level.

For example, it could be one of the following levels:

  • The subscription level.
  • The resource group level.
  • The resource level (for example, a Media account).

For more information, see Create an Azure service principal with the Azure CLI

Also see Manage Role-Based Access Control with the Azure command-line interface.

Next steps

Get started with uploading files to your account.