快速入门:媒体服务帐户 ARM 模板

Media Services logo v3


警告

Azure 媒体服务将于 2024 年 6 月 30 日停用。 有关详细信息,请参阅 AMS 停用指南

本文介绍如何使用Azure 资源管理器模板(ARM 模板)创建媒体服务帐户。

熟悉 ARM 模板的读者可以继续阅读部署部分

先决条件

如果没有 Azure 订阅,可在开始前创建一个试用帐户

如果之前从未部署过 ARM 模板,请阅读 Azure ARM 模板并浏览教程,这会很有帮助。

查看模板

本快速入门中使用的模板来自 Azure 快速启动模板

该模板中定义了三种 Azure 资源类型:

设置帐户


az account set --subscription {your subscription name or id}

创建资源组


az group create --name {the name you want to give your resource group} --location "{pick a location}"

向部署文件分配变量

为方便起见,请创建一个存储模板文件路径的变量。 此变量使你能够更轻松地运行部署命令,因为无需在每次部署时都重新键入路径。


templateFile="{provide the path to the template file}"

部署模板

系统会提示输入媒体服务帐户名。


az deployment group create --name {the name you want to give to your deployment} --resource-group {the name of resource group you created} --template-file $templateFile

查看已部署的资源

应会显示如下所示的 JSON 响应:

{
  "id": "/subscriptions/{subscriptionid}/resourceGroups/amsarmquickstartrg/providers/Microsoft.Resources/deployments/amsarmquickstartdeploy",
  "location": null,
  "name": "amsarmquickstartdeploy",
  "properties": {
    "correlationId": "{correlationid}",
    "debugSetting": null,
    "dependencies": [
      {
        "dependsOn": [
          {
            "id": "/subscriptions/{subscriptionid}/resourceGroups/amsarmquickstartrg/providers/Microsoft.Storage/storageAccounts/storagey44cfdmliwatk",
            "resourceGroup": "amsarmquickstartrg",
            "resourceName": "storagey44cfdmliwatk",
            "resourceType": "Microsoft.Storage/storageAccounts"
          }
        ],
        "id": "/subscriptions/35c2594a-23da-4fce-b59c-f6fb9513eeeb/resourceGroups/amsarmquickstartrg/providers/Microsoft.Media/mediaServices/{accountname}",
        "resourceGroup": "amsarmquickstartrg",
        "resourceName": "{accountname}",
        "resourceType": "Microsoft.Media/mediaServices"
      }
    ],
    "duration": "PT1M10.8615001S",
    "error": null,
    "mode": "Incremental",
    "onErrorDeployment": null,
    "outputResources": [
      {
        "id": "/subscriptions/{subscriptionid}/resourceGroups/amsarmquickstartrg/providers/Microsoft.Media/mediaServices/{accountname}",
        "resourceGroup": "amsarmquickstartrg"
      },
      {
        "id": "/subscriptions/{subscriptionid}/resourceGroups/amsarmquickstartrg/providers/Microsoft.Storage/storageAccounts/storagey44cfdmliwatk",
        "resourceGroup": "amsarmquickstartrg"
      }
    ],
    "outputs": null,
    "parameters": {
      "mediaServiceName": {
        "type": "String",
        "value": "{accountname}"
      }
    },
    "parametersLink": null,
    "providers": [
      {
        "id": null,
        "namespace": "Microsoft.Media",
        "registrationPolicy": null,
        "registrationState": null,
        "resourceTypes": [
          {
            "aliases": null,
            "apiVersions": null,
            "capabilities": null,
            "locations": [
              "chinaeast2"
            ],
            "properties": null,
            "resourceType": "mediaServices"
          }
        ]
      },
      {
        "id": null,
        "namespace": "Microsoft.Storage",
        "registrationPolicy": null,
        "registrationState": null,
        "resourceTypes": [
          {
            "aliases": null,
            "apiVersions": null,
            "capabilities": null,
            "locations": [
              "chinaeast2"
            ],
            "properties": null,
            "resourceType": "storageAccounts"
          }
        ]
      }
    ],
    "provisioningState": "Succeeded",
    "templateHash": "{templatehash}",
    "templateLink": null,
    "timestamp": "2020-11-24T23:25:52.598184+00:00",
    "validatedResources": null
  },
  "resourceGroup": "amsarmquickstartrg",
  "tags": null,
  "type": "Microsoft.Resources/deployments"
}

在 Azure 门户中,确认已创建资源。

清理资源

如果你不打算使用刚刚创建的资源,则可以删除资源组。


az group delete --name {name of the resource group}