Use Azure CLI to create an Azure AD app and configure it to access Media Services API
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.
Prerequisites
- An Azure account. For details, see Azure free trial.
- A Media Services account. For more information, see Create an Azure Media Services account using the Azure portal.
Use the Azure Cloud Shell
Sign in to the Azure portal.
Launch the Cloud Shell from the upper navigation pane of the portal.
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> --role Contributor
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/microsoft.media/mediaservices/sbbash
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