要求: 我需要使用 ARM 模板在 azure 中创建以下两个资源,即“azure storage account”和“azure storage sync service”。
步骤: 我有两个 ARM 模板,一个用于创建“azure 存储帐户”,另一个用于创建“azure 存储同步服务”。
我试过以下手臂模板,但它不能正常工作。有人帮我弄到这个吗?
主模板存储同步服务/deploy.json { "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "内容版本": "1.0.0.0", “参数”: { “存储同步服务名称”:{ “类型”:“字符串”, “默认值”: ””, “最大长度”:25 }, “地点”: { “类型”:“字符串”, “元数据”:{ “默认值”: ”” } }, “同步组名”:{ “类型”:“字符串”, “默认值”:“ServerA-P01”, “元数据”:{ "description": "存储端点的名称。" } }, “服务器ID”:{ “类型”:“字符串”, “默认值”:””, “元数据”:{ "description": "存储端点的名称。" } }, “启用服务器端点”:{ “类型”:“布尔”, “默认值”:假 }, “azureFileShareName”:{ “类型”:“字符串”, “默认值”: ” ”, “元数据”:{ "description": "文件共享的名称。" } }, “云端点”:{ “类型”:“字符串”, “默认值”:“bhendpoints”, “元数据”:{ "description": "文件共享的名称。" } }, “storageAccountResourceId”:{ “类型”:“安全字符串”, “默认值”: ””, “元数据”:{ "description": "存储账户访问密钥。" } }, “storageAccountTenantId”:{ “类型”:“字符串”, “默认值”: ””, “元数据”:{ "description": "存储服务器 ID。" } }, “cloudTiering”:{ “类型”:“字符串”, “元数据”:{ “描述”:“描述” } }, “volumeFreeSpacePercent”:{ “类型”:“字符串”, “元数据”:{ “描述”:“描述” } }, “服务器本地路径”:{ “类型”:“字符串”, “元数据”:{ “描述”:“描述” } }, “日期政策”:{ “类型”:“字符串”, “元数据”:{ “描述”:“描述” } } “变量”:{ }, “资源”:[
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2021-04-01",
"name": "linkedTemplate",
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[uri(deployment().properties.templatelink.uri, 'C:\\Users\\User\\Desktop\\poc\\storageaccount\\deploy.json')]",
"contentVersion": "1.0.0.0"
},
"parameters": {
"deploymentFilePath": {
"value": "[parameters('deploymentFilePath')]"
}
}
}
},
{
"type": "Microsoft.StorageSync/storageSyncServices",
"apiVersion": "2022-06-01",
"name": "[parameters('storageSyncServicesname')]",
"location": "[parameters('Location')]",
"properties": {
"incomingTrafficPolicy": "AllowAllTraffic"
}
},
{
"type": "Microsoft.StorageSync/storageSyncServices/syncGroups",
"apiVersion": "2022-06-01",
"name": "[concat(parameters('storageSyncServicesname'), '/', if(not(empty(parameters('SyncGroupName'))), parameters('SyncGroupName'), 'defaultValue'))]",
"dependsOn": [
"[resourceId('Microsoft.StorageSync/storageSyncServices', parameters('storageSyncServicesname'))]
],
"properties": {}
},
{
"condition": "[parameters('enableServerEndpoint')]",
"type": "Microsoft.StorageSync/storageSyncServices/syncGroups/cloudEndpoints",
"apiVersion": "2022-06-01",
"name": "[concat(parameters('storageSyncServicesname'), '/', parameters('SyncGroupName'), '/', parameters('cloudendpoint'))]",
"dependsOn": [
"[resourceId('Microsoft.StorageSync/storageSyncServices', parameters('storageSyncServicesname'))]",
"[resourceId('Microsoft.StorageSync/storageSyncServices/syncGroups', parameters('storageSyncServicesname'), parameters('SyncGroupName'))]"
],
"properties": {
"storageAccountResourceId": "[reference('linkedTemplate').outputs.storageAccountResourceId.value]",
"azureFileShareName": "[parameters('azureFileShareName')]",
"storageAccountTenantId": "[parameters('storageAccountTenantId')]",
"friendlyName": "[parameters('azureFileShareName')]"
}
},
{
"condition": "[parameters('enableServerEndpoint')]",
"type": "Microsoft.StorageSync/storageSyncServices/syncGroups/serverEndpoints",
"apiVersion": "2019-02-01",
"name": "[concat(parameters('storageSyncServicesname'), '/', parameters('SyncGroupName'), '/', parameters('azureFileShareName'))]",
"dependsOn": [
"[resourceId('Microsoft.StorageSync/storageSyncServices', parameters('storageSyncServicesname'))]",
"[resourceId('Microsoft.StorageSync/storageSyncServices/syncGroups/cloudEndpoints', parameters('storageSyncServicesname'), parameters('SyncGroupName'), parameters('cloudendpoint'))]"
],
"properties": {
"serverLocalPath": "[parameters('serverLocalPath')]",
"cloudTiering": "[parameters('cloudTiering')]",
"volumeFreeSpacePercent": "[parameters('volumeFreeSpacePercent')]",
"tierFilesOlderThanDays": "[parameters('Datepolicy')]",
"storageAccountResourceId":"[reference('linkedTemplate').outputs.storageAccountResourceId.value]"
"serverResourceId": "[resourceId('Microsoft.StorageSync/storageSyncServices/registeredServers', parameters('storageSyncServicesname'), parameters('serverID'))]",
"offlineDataTransfer": "Off",
"initialDownloadPolicy": "NamespaceOnly",
"localCacheMode": "UpdateLocallyCachedFiles",
"initialUploadPolicy": "ServerAuthoritative"
}
}
]
}
链接模板 storageaccount\deploy.json
{ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "内容版本": "1.0.0.0", “参数”: { “存储帐户名”:{ “默认值”:“msftstoragepoc1998”, “类型”:“字符串” },
"fileShareName": {
"defaultValue": "fileshere1",
"type": "String"
},
"location": {
"type": "string",
"defaultValue": "West US 2",
"metadata": {
"description": "The location where the resources will be created."
}
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2022-09-01",
"name": "[parameters('storageAccountName')]",
"location": "[parameters('location')]",
"sku": {
"name": "Standard_RAGRS",
"tier": "Standard"
},
"kind": "StorageV2",
"properties": {
"supportsHttpsTrafficOnly": true,
"encryption": {
"requireInfrastructureEncryption": false,
"services": {
"file": {
"keyType": "Account",
"enabled": true
},
"blob": {
"keyType": "Account",
"enabled": true
}
},
"keySource": "Microsoft.Storage"
},
"accessTier": "Hot",
"networkAcls": {
"bypass": "AzureServices",
"virtualNetworkRules": [],
"ipRules": [],
"defaultAction": "Allow"
},
"allowBlobPublicAccess": true,
"allowCrossTenantReplication": true,
"allowSharedKeyAccess": true,
"defaultToOAuthAuthentication": false,
"dnsEndpointType": "Standard",
"minimumTlsVersion": "TLS1_2",
"publicNetworkAccess": "Enabled"
}
},
{
"type": "Microsoft.Storage/storageAccounts/fileServices/shares",
"apiVersion": "2019-06-01",
"name": "[concat(parameters('storageAccountName'), '/default/', parameters('fileShareName'))]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName'))]"
],
"properties": {
"accessTier": "TransactionOptimized",
"shareQuota": 5120,
"enabledProtocols": "SMB"
}
}
],
"outputs": {
"storageAccountResourceId": {
"type": "object",
"value": "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName'))]",
"metadata": {
"description": "The Resource Id of the Storage Account."
}
}
}
}
当我使用 Powershell commend 运行它时,我得到了这样的错误
线| 15 |新的 AzResourceGroupDeployment` | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 09:22:23 - 部署“deploy”因错误而失败。显示 1 个错误,共 1 个。状态消息:无法处理模板 |资源的语言表达 | “/subscriptions/subscribtionid/resourceGroups/MSFT-assessment/providers/Microsoft.Resources/deployments/linkedTemplate”,位于“172”行和“9”列。 “语言表达式属性‘templatelink’不存在,可用属性为‘template、templateHash、parameters、mode、provisioningState’。” (代码:无效模板)CorrelationId:df65adfa-1459-4e81-83c8-7f89c3e81128
要求: 我需要使用 ARM 模板在 azure 中创建以下两个资源,即“azure storage account”和“azure storage sync service”。
步骤: 我有两个 ARM 模板,一个用于创建“azure 存储帐户”,另一个用于创建“azure 存储同步服务”。