你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
本快速入门介绍如何使用 Azure 资源管理器模板(ARM 模板)创建存储任务。
Azure 资源管理器模板是一个 JavaScript 对象表示法(JSON)文件,用于定义项目的基础结构和配置。 模板使用声明性语法。 你可以在不编写用于创建部署的编程命令序列的情况下,描述预期部署。
如果你的环境满足先决条件,并且你熟悉如何使用 ARM 模板,请选择“部署到 Azure”按钮。 Azure 门户中会打开模板。
先决条件
如果没有 Azure 订阅,请在开始之前创建一个免费帐户。
查看模板
本快速入门中使用的模板来自 Azure 快速入门模板。
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.32.4.45862",
"templateHash": "11663963517791910133"
}
},
"parameters": {
"storageTaskName": {
"type": "string",
"minLength": 3,
"maxLength": 18,
"metadata": {
"description": "The name of storage task."
}
},
"description": {
"type": "string",
"metadata": {
"description": "A description of the storage task."
}
},
"___location": {
"type": "string",
"defaultValue": "[resourceGroup().___location]",
"metadata": {
"description": "The region in which to create the storage task."
}
},
"lockedUntilDate": {
"type": "string",
"defaultValue": "[dateTimeAdd(utcNow(), 'P1D')]",
"metadata": {
"description": "Locks the file for one day."
}
}
},
"resources": [
{
"type": "Microsoft.StorageActions/storageTasks",
"apiVersion": "2023-01-01",
"name": "[parameters('storageTaskName')]",
"___location": "[parameters('___location')]",
"identity": {
"type": "SystemAssigned"
},
"properties": {
"action": {
"if": {
"condition": "[[[endsWith(Name, '.docx')]]",
"operations": [
{
"name": "SetBlobImmutabilityPolicy",
"onSuccess": "continue",
"onFailure": "break",
"parameters": {
"untilDate": "[parameters('lockedUntilDate')]",
"mode": "locked"
}
},
{
"name": "SetBlobTags",
"onSuccess": "continue",
"onFailure": "break",
"parameters": {
"tagsetImmutabilityUpdatedBy": "StorageTaskQuickstart"
}
}
]
}
},
"description": "[parameters('description')]",
"enabled": true
}
}
]
}
部署模板
还可以使用 Azure PowerShell、Azure CLI 和 REST API。 若要了解其他部署方法,请参阅部署模板。
查看已部署的资源
在 Azure 门户中,搜索“存储任务”。 然后,在“服务”下选择“存储任务 - Azure 存储操作”。
在存储任务列表中,搜索已部署的存储任务的名称。
清理资源
不再需要资源组时,可将其删除。 资源组和资源组中的所有资源都会被删除。 使用以下命令删除资源组及其包含的所有资源。
az group delete --name <resource-group-name>
将 <resource-group-name>
替换为资源组的名称。
后续步骤
将存储任务分配给存储帐户。