注意
你将需要一个 Azure 订阅,在该订阅中,可以访问资源组的参与者角色和用户访问管理员角色,你将在该资源组下创建新资源(用户分配的托管标识、存储帐户、视频分析器帐户)。 如果没有适当的权限,请联系帐户管理员,让其授予此类权限。 关联的存储帐户必须与视频分析器帐户位于同一区域。 建议使用标准常规用途 v2 存储帐户。
使用模板创建视频分析器帐户
该模板中定义了以下资源:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"namePrefix": {
"metadata": {
"description": "Used to qualify the names of all of the resources created in this template."
},
"defaultValue": "avasample",
"type": "string",
"minLength": 3,
"maxLength": 13
}
},
"variables": {
"storageAccountName": "[concat(parameters('namePrefix'),uniqueString(resourceGroup().id))]",
"accountName": "[concat(parameters('namePrefix'),uniqueString(resourceGroup().id))]",
"managedIdentityName": "[concat(parameters('namePrefix'),'-',resourceGroup().name,'-storage-access-identity')]"
},
"resources": [
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2020-10-01",
"name": "deploy-storage-and-identity",
"properties": {
"mode": "Incremental",
"expressionEvaluationOptions": {
"scope": "Inner"
},
"parameters": {
"namePrefix": {
"value": "[parameters('namePrefix')]"
},
"managedIdentityName": {
"value": "[variables('managedIdentityName')]"
}
},
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"namePrefix": {
"type": "string"
},
"managedIdentityName": {
"type": "string"
}
},
"variables": {
"storageAccountName": "[concat(parameters('namePrefix'),uniqueString(resourceGroup().id))]",
"managedIdentityName": "[parameters('managedIdentityName')]",
"storageBlobDataContributorAssignment": "[guid('Storage Blob Data Contributor',variables('managedIdentityName'))]",
"storageBlobDataContributorDefinitionId": "[concat(resourceGroup().id, '/providers/Microsoft.Authorization/roleDefinitions/', 'ba92f5b4-2d11-453d-a403-e96b0029c9fe')]",
"readerAssignment": "[guid('Reader',variables('managedIdentityName'))]",
"readerDefinitionId": "[concat(resourceGroup().id, '/providers/Microsoft.Authorization/roleDefinitions/', 'acdd72a7-3385-48ef-bd42-f606fba81ae7')]"
},
"resources": [
{
"type": "Microsoft.ManagedIdentity/userAssignedIdentities",
"name": "[variables('managedIdentityName')]",
"apiVersion": "2015-08-31-preview",
"location": "[resourceGroup().location]"
},
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-04-01",
"name": "[variables('storageAccountName')]",
"location": "[resourceGroup().location]",
"sku": {
"name": "Standard_LRS"
},
"kind": "StorageV2",
"properties": {
"accessTier": "Hot"
}
},
{
"name": "[concat(variables('storageAccountName'), '/Microsoft.Authorization/', variables('storageBlobDataContributorAssignment'))]",
"type": "Microsoft.Storage/storageAccounts/providers/roleAssignments",
"apiVersion": "2021-04-01-preview",
"dependsOn": [
"[variables('managedIdentityName')]",
"[variables('storageAccountName')]"
],
"properties": {
"roleDefinitionId": "[variables('storageBlobDataContributorDefinitionId')]",
"principalId": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities',variables('managedIdentityName')), '2018-11-30').principalId]",
"principalType": "ServicePrincipal"
}
},
{
"name": "[concat(variables('storageAccountName'), '/Microsoft.Authorization/', variables('readerAssignment'))]",
"type": "Microsoft.Storage/storageAccounts/providers/roleAssignments",
"apiVersion": "2021-04-01-preview",
"dependsOn": [
"[variables('managedIdentityName')]",
"[variables('storageAccountName')]"
],
"properties": {
"roleDefinitionId": "[variables('readerDefinitionId')]",
"principalId": "[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities',variables('managedIdentityName')), '2018-11-30').principalId]",
"principalType": "ServicePrincipal"
}
}
],
"outputs": {}
}
}
},
{
"type": "Microsoft.Media/videoAnalyzers",
"comments": "The Azure Video Analyzer account",
"apiVersion": "2021-05-01-preview",
"name": "[variables('accountName')]",
"location": "[resourceGroup().location]",
"dependsOn": [
"deploy-storage-and-identity"
],
"properties": {
"storageAccounts": [
{
"id": "[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]",
"identity": {
"userAssignedIdentity": "[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities',variables('managedIdentityName'))]"
}
}
]
},
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities',variables('managedIdentityName'))]": {}
}
}
}
],
"outputs": { }
}
注意
模板将嵌套部署用于角色分配,确保在部署视频分析器帐户资源之前可使用此部署。
部署模板
要登录到 Azure 并打开模板,请单击“部署到 Azure”按钮。

选择或输入以下值。 使用可用的默认值。
- 订阅:选择一个 Azure 订阅。
- 资源组:从下拉列表中选择现有资源组,或选择“新建”并输入资源组的唯一名称,然后单击“确定” 。
- 位置:选择一个位置。 例如美国西部 2。
- 名称前缀:提供作为资源名称前缀的字符串(建议使用默认值)。
选择“查看 + 创建”。 在验证完成后,选择“创建”,以创建和部署该模板。
在上述过程中,使用的是 Azure 门户来部署模板。 除了 Azure 门户,还可以使用 Azure CLI、Azure PowerShell 和 REST API。 若要了解其他部署方法,请参阅部署模板。
部署后的步骤
可以选择将现有的 IoT 中心附加到视频分析器帐户,此操作将会需要现有的 UAMI。
- 在资源已完成部署后,单击“转到资源”。
- 在设置下,选择“IoT 中心”,然后单击“附加” 。 在“附加 IoT 中心”配置浮出式边栏选项卡中,输入所需值:
- 订阅 - 请选择已经创建了 IoT 中心的 Azure 订阅名称
- IoT 中心 - 请选择所需的 IoT 中心
- 托管标识 - 请选择要用于访问 IoT 中心的现有的 UAMI
- 单击“保存”,以将 IoT 中心链接到视频分析器帐户。
查看已部署的资源
你可以使用 Azure 门户查看创建的帐户和其他资源。 部署完成后,请选择“转到资源组”以查看帐户和其他资源。
清理资源
如果不再需要资源组,可以将其删除,这将删除帐户和资源组中的所有资源。
- 选择“资源组”。
- 在资源组页上,选择“删除”。
- 出现提示时,键入资源组的名称,然后选择“删除”。