获取访问媒体服务 API 的凭据Get credentials to access Media Services API

媒体服务徽标 v3media services logo v3


通过 Azure AD 身份验证访问 Azure 媒体服务 API 时,可使用下面两种身份验证选项:When you use Azure AD authentication to access the Azure Media Services API, you have two authentication options:

  • 服务主体身份验证(推荐)Service principal authentication (recommended)

    验证服务。Authenticate a service. 常常使用这种身份验证方法的应用程序是运行守护程序服务、中间层服务或计划作业的应用程序:Web 应用程序、函数应用程序、逻辑应用程序、API 或微服务。Applications that commonly use this authentication method are apps that run daemon services, middle-tier services, or scheduled jobs: web apps, function apps, logic apps, APIs, or a microservice.

  • 用户身份验证User authentication

    验证使用应用程序与媒体服务资源进行交互的用户。Authenticate a person who is using the app to interact with Media Services resources. 交互式应用程序应先提示用户输入凭据。The interactive application should first prompt the user for credentials. 例如,授权用户用来监视编码作业或实时传送视频流的管理控制台应用程序。An example is a management console app used by authorized users to monitor encoding jobs or live streaming.

本文介绍了获取访问媒体服务 API 的凭据的步骤。This article describes steps for getting credentials to access Media Services API. 有以下选项卡可供选择。Choose from the following tabs.

先决条件Prerequisites

API 访问API access

通过“API 访问”页面,可选择要用来连接 API 的身份验证方法。The API access page lets you select the authentication method you want to use to connect to the API. 该页面还提供了连接到 API 所需的值。The page also provides the values you need to connect to the API.

  1. Azure 门户中,选择媒体服务帐户。In the Azure portal, select your Media Services account.
  2. 选择左侧导航栏上的“API 访问(新)”边栏选项卡。Select the API access (new) blade on the left navigation bar.
  3. 在“连接到媒体服务 API”下,选择要连接到的媒体服务 API 版本(该服务的最新版本是 V3)。Under Connect to Media Services API, select the Media Services API version you want to connect to (V3 is the latest version of the service).

使用 Azure Active Directory (Azure AD) 应用和密钥对服务进行身份验证。Authenticates a service using an Azure Active Directory (Azure AD) app and secret. 建议将它用于对媒体服务 API 的任何中间层服务调用,This is recommended for any middle-tier services calling to the Media Services API. 例如 Web 应用、Functions、逻辑应用、API 和微服务。Examples are Web Apps, Functions, Logic Apps, APIs, and microservices. 这是推荐的身份验证方法。This is the recommended authentication method.

管理 Azure AD 应用和密钥Manage your Azure AD app and secret

通过“理 AAD 应用和密钥”部分,可选择或创建新的 Azure AD 应用并生成密钥。The Manage your AAD app and secret section lets you select or create a new Azure AD app and generate a secret. 出于安全原因,边栏选项卡关闭后密钥无法显示。For security purposes, the secret cannot be shown after the blade is closed. 应用程序使用应用程序 ID 和密钥进行验证,以便为媒体服务获取有效的令牌。The application uses the application ID and secret for authentication to obtain a valid token for media services.

请确保你拥有足够的权限,可向 Azure AD 租户注册应用程序,并将应用程序分配给 Azure 订阅中的角色。Make sure that you have sufficient permissions to register an application with your Azure AD tenant and to assign the application to a role in your Azure subscription. 有关详细信息,请参阅所需的权限For more information, see Required permissions.

连接到媒体服务 APIConnect to Media Services API

在“连接到媒体服务 API”页面,可查看用于连接服务主体应用程序的值。The Connect to Media Services API provides you with values that you use to connect your service principal application. 可获取文本值,也可复制 JSON 或 XML 块。You can get text values or copy the JSON or XML blocks.

用户身份验证User authentication

此选项可用于对使用应用与媒体服务资源进行交互的 Azure Active Directory 的员工或成员进行身份验证。This option could be used to authenticate an employee or member of an Azure Active Directory who is using an app to interact with Media Services resources. 交互式应用程序应先提示用户输入用户凭据。The interactive application should first prompt the user for the user's credentials. 这种身份验证方法应仅用于管理应用程序。This authentication method should only be used for Management applications.

连接到媒体服务 APIConnect to Media Services API

从“连接到媒体服务 API”部分复制凭据来连接用户应用程序。Copy your credentials to connect your user application from the Connect to Media Services API section. 可获取文本值,也可复制 JSON 或 XML 块。You can get text values or copy the JSON or XML blocks.

后续步骤Next steps

教程:使用媒体服务 v3 上传编码和流式传输视频Tutorial: Upload, encode, and stream videos with Media Services v3.