使用 Azure CLI 创建 Azure AD 应用并将其配置为访问媒体服务 APIUse Azure CLI to create an Azure AD app and configure it to access Media Services API

媒体服务徽标media services logo


备注

不会向媒体服务 v2 添加任何新特性或新功能。No new features or functionality are being added to Media Services v2.
查看最新版本:媒体服务 v3Check out the latest version, Media Services v3. 另请参阅从 v2 到 v3 的迁移指南Also, see migration guidance from v2 to v3

本主题展示了如何使用 Azure CLI 创建 Azure Active Directory (Azure AD) 应用程序和服务主体,以便访问 Azure 媒体服务资源。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

使用 PowerShellUse the PowerShell

登录 Azure 门户Sign in to the Azure portal.

使用 Azure CLI 创建 Azure AD 应用并配置为访问媒体帐户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/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).

有关详细信息,请参阅使用 Azure CLI 创建 Azure 服务主体For more information, see Create an Azure service principal with the Azure CLI

另请参阅使用 Azure CLI 添加或删除 Azure 角色分配Also see Add or remove Azure role assignments using Azure CLI.

后续步骤Next steps

开始将文件上传到帐户Get started with uploading files to your account.