创建 Azure 媒体服务帐户Create an Azure Media Services account

若要开始加密、编码、分析、管理和流式处理 Azure 中的媒体内容,需要创建媒体服务帐户。To start encrypting, encoding, analyzing, managing, and streaming media content in Azure, you need to create a Media Services account. 媒体服务帐户需与一个或多个存储帐户相关联。The Media Services account needs to be associated with one or more storage accounts.

Note

媒体服务帐户和所有关联的存储帐户必须位于同一 Azure 订阅中。The Media Services account and all associated storage accounts must be in the same Azure subscription. 强烈建议在媒体服务帐户所在的位置使用存储帐户,避免额外的延迟和数据出口成本。It is strongly recommended to use storage accounts in the same location as the Media Services account to avoid additional latency and data egress costs.

本文介绍使用 Azure CLI 创建新 Azure 媒体服务帐户的步骤。This article describes steps for creating a new Azure Media Services account using the Azure CLI.

先决条件Prerequisites

一个有效的 Azure 订阅。An active Azure subscription. 如果没有 Azure 订阅,可在开始前创建一个 1 元人民币试用帐户If you don't have an Azure subscription, create a 1rmb trial account before you begin.

CLICLI

可以在本地安装 CLI。You can install the CLI locally. 有关适用于你的平台的说明,请参阅安装 Azure CLISee Install the Azure CLI for instructions for your platform.

登录Sign in

使用本地安装的 CLI 需要登录到 Azure。Using a local install of the CLI requires signing in to Azure. 使用 az login 命令登录。Sign in with the az login command.

如果 CLI 可以打开默认的浏览器,则它会打开该浏览器并加载登录页。If the CLI can open your default browser, it will do so and load a sign-in page. 否则,你需要打开一个浏览器页面,在浏览器中导航到 https://microsoft.com/deviceloginchina 后,按照有关命令行的说明输入授权代码。Otherwise, you need to open a browser page and follow the instructions on the command line to enter an authorization code after navigating to https://microsoft.com/deviceloginchina in your browser.

指定文件位置Specify location of files

许多媒体服务 CLI 命令允许你通过文件名来传递参数。Many Media Services CLI commands allow you to pass a parameter with a file name.

需要根据所用的 OS 或 Shell(Bash 或 PowerShell)指定文件路径。You need to specify the file path according to the OS or Shell (Bash or PowerShell) that you are using. 下面是一些示例:Below are some examples:

文件(所有 OS)的相对路径Relative path to the file (all OS)

  • @"mytestfile.json"
  • @"../mytestfile.json"

Linux/Mac 和 Windows OS 上的绝对文件路径Absolute file path on Linux/Mac and Windows OS

  • @ "/usr/home/mytestfile.json"
  • @"c:\tmp\user\mytestfile.json"

如果命令要求提供文件路径,请使用 {file}Use {file} if the command is asking for a path to the file. 例如,az ams transform create -a amsaccount -g resourceGroup -n custom --preset .\customPreset.jsonFor example, az ams transform create -a amsaccount -g resourceGroup -n custom --preset .\customPreset.json.
如果命令将加载指定的文件,请使用 @{file}Use @{file} if the command is going to load the specified file. 例如,az ams account-filter create -a amsaccount -g resourceGroup -n filterName --tracks @tracks.jsonFor example, az ams account-filter create -a amsaccount -g resourceGroup -n filterName --tracks @tracks.json.

设置 Azure 订阅Set the Azure subscription

在以下命令中,为媒体服务帐户提供想要使用的 Azure 订阅 ID。In the following command, provide the Azure subscription ID that you want to use for the Media Services account. 导航到订阅即可查看有权访问的订阅列表。You can see a list of subscriptions that you have access to by navigating to Subscriptions.

az account set --subscription mySubscriptionId

创建媒体服务帐户Create a Media Services account

首先需创建媒体服务帐户。You first need to create a Media Services account. 本部分介绍使用 Azure CLI 创建帐户所需的内容。This section shows what you need for the account creation using the Azure CLI.

创建资源组Create a resource group

使用以下命令创建资源组。Create a resource group using the following command. Azure 资源组是在其中部署和管理资源(例如 Azure 媒体服务帐户和关联的存储帐户)的逻辑容器。An Azure resource group is a logical container into which resources like Azure Media Services accounts and the associated Storage accounts are deployed and managed.

可以将 amsResourceGroup 替换为你的值。You can substitute amsResourceGroup with your value.

az group create --name amsResourceGroup --location chinaeast

创建存储帐户Create a storage account

创建媒体服务帐户时,需要提供 Azure 存储帐户资源的名称。When creating a Media Services account, you need to supply the name of an Azure Storage account resource. 指定存储帐户会附加到媒体服务帐户。The specified storage account is attached to your Media Services account. 若要详细了解如何在媒体服务中使用存储帐户,请参阅存储帐户For more information about how storage accounts are used in Media Services, see Storage accounts.

必须具有一个主存储帐户,并且可以拥有任意数量的与媒体服务帐户关联的辅助存储帐户 。You must have one Primary storage account and you can have any number of Secondary storage accounts associated with your Media Services account. 媒体服务支持常规用途 v2 (GPv2) 或常规用途 v1 (GPv1) 帐户 。Media Services supports General-purpose v2 (GPv2) or General-purpose v1 (GPv1) accounts. 不允许将仅限 Blob 的帐户作为主帐户Blob only accounts are not allowed as Primary. 若要了解存储帐户的详细信息,请参阅 Azure 存储帐户选项If you want to learn more about storage accounts, see Azure Storage account options.

在此示例中,我们创建一个常规用途 v2 标准 LRS 帐户。In this example, we create a General Purpose v2, Standard LRS account. 若要通过存储帐户进行试验,请使用 --sku Standard_LRSIf you want to experiment with storage accounts, use --sku Standard_LRS. 但是,在选取用于生产的 SKU 时,应考虑 --sku Standard_RAGRS,以便通过异地复制确保业务连续性。However, when picking a SKU for production you should consider, --sku Standard_RAGRS, which provides geographic replication for business continuity. 有关详细信息,请参阅存储帐户For more information, see storage accounts.

以下命令创建将与媒体服务帐户相关联的存储帐户。The following command creates a Storage account that is going to be associated with the Media Services account. 在以下脚本中,可以将 storageaccountforams 替换为你的值。In the script below, you can substitute storageaccountforams with your value. amsResourceGroup 必须与在上一步中为资源组指定的值匹配。amsResourceGroup must match the value you gave for the resource group in the previous step. 存储帐户名称的长度必须小于 24。The storage account name must have length less than 24.

az storage account create --name storageaccountforams \  
  --kind StorageV2 \
  --sku Standard_LRS \
  -l chinaeast \
  -g amsResourceGroup

创建媒体服务帐户Create a Media Services account

以下 Azure CLI 命令创建新的媒体服务帐户。The following Azure CLI command creates a new Media Services account. 可以替换以下值:amsaccount storageaccountforams(必须与提供给存储帐户的值相符)和 amsResourceGroup(必须与提供给资源组的值相符)。You can replace the following values: amsaccount storageaccountforams (must match the value you gave for your storage account), and amsResourceGroup (must match the value you gave for the resource group).

az ams account create --name amsaccount \
  -l chinaeast \
  -g amsResourceGroup --storage-account storageaccountforams

后续步骤Next steps

另请参阅See also

Azure CLIAzure CLI