我正在尝试使用ARM模板部署Redis缓存,但是它始终失败并显示以下错误:
{“代码”:“ DeploymentFailed”,“消息”:“至少一项资源部署 手术失败。请列出部署操作以获取详细信息。 请参阅https://aka.ms/arm-debug以了解用法 详细信息。“,”详细信息“:[{”代码“:” BadRequest“,”消息“:” {\ r \ n \“错误\”: {\ r \ n \“ code \”:\“ LinkedInvalidPropertyId \”,\ r \ n \“ message \”: \“路径处的属性ID'GET-PREREQ-existingDiagnosticsStorageAccountId' 'properties.storageAccountId'无效。期望完全合格 以'/ subscriptions / {subscriptionId}'开头的资源ID或 '/providers/{resourceProviderNamespace}/'.\"\r\n} \ r \ n}“}]}
在线确定了资源,但我无法弄清楚到底出了什么问题。虽然确实创建了Redis Cache资源,但是部署并不完全成功。以下似乎失败了: https://imgur.com/a/xsp0OqL https://imgur.com/a/mpBBIAm
azuredeployredis.json
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
"contentVersion": "1.0.0.0",
"parameters": {
"redisCacheName": {
"type": "string",
"defaultValue": "defaultRedisCacheName",
"metadata": {
"description": "The name of the Azure Redis Cache to create."
}
},
"redisCacheSKU": {
"type": "string",
"allowedValues": [
"Basic",
"Standard",
"Premium"
],
"defaultValue": "Standard",
"metadata": {
"description": "The pricing tier of the new Azure Redis Cache."
}
},
"redisCacheFamily": {
"type": "string",
"defaultValue": "C",
"metadata": {
"description": "The family for the sku."
},
"allowedValues": [
"C",
"P"
]
},
"redisCacheCapacity": {
"type": "int",
"allowedValues": [
0,
1,
2,
3,
4,
5,
6
],
"defaultValue": 1,
"metadata": {
"description": "The size of the new Azure Redis Cache instance. "
}
},
"enableNonSslPort": {
"type": "bool",
"defaultValue": false,
"metadata": {
"description": "A boolean value that indicates whether to allow access via non-SSL ports."
}
},
"diagnosticsEnabled": {
"type": "bool",
"defaultValue": false,
"metadata": {
"description": "A value that indicates whether diagnostics should be saved to the specified storage account."
}
},
"existingDiagnosticsStorageAccountId": {
"type": "string",
"metadata": {
"description": "Existing storage account for diagnostics."
}
}
},
"resources": [
{
"apiVersion": "2015-08-01",
"name": "[parameters('redisCacheName')]",
"type": "Microsoft.Cache/Redis",
"location": "[resourceGroup().location]",
"properties": {
"enableNonSslPort": "[parameters('enableNonSslPort')]",
"sku": {
"capacity": "[parameters('redisCacheCapacity')]",
"family": "[parameters('redisCacheFamily')]",
"name": "[parameters('redisCacheSKU')]"
}
},
"resources": [
{
"apiVersion": "2017-05-01-preview",
"type": "Microsoft.Cache/redis/providers/diagnosticsettings",
"name": "[concat(parameters('redisCacheName'), '/Microsoft.Insights/', parameters('redisCacheName'))]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Cache/Redis/', parameters('redisCacheName'))]"
],
"properties": {
"storageAccountId": "[parameters('existingDiagnosticsStorageAccountId')]",
"metrics": [
{
"timeGrain": "AllMetrics",
"enabled": "[parameters('diagnosticsEnabled')]",
"retentionPolicy": {
"days": 90,
"enabled": "[parameters('diagnosticsEnabled')]"
}
}
]
}
}
]
}
]
}
azuredeployredis.parameters.json:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"redisCacheName": {
"value": "xyz-redis-cache"
},
"existingDiagnosticsStorageAccountId": {
"value": "GET-PREREQ-existingDiagnosticsStorageAccountId"
}
}
}
答案 0 :(得分:1)
我的意思是,该错误明确表明您需要将resourceId而不是资源名称传递给properties.storageAccountId。它应该看起来像这样:
/subscriptions/guid/resourceGroups/rgname/providers/Microsoft.Storage/storageAccounts/storagename
您可以使用resourceId()
函数来计算:
resourceId('subscriptionId', 'resourceGroupname', 'Microsoft.Storage/storageAccounts', 'storageaccountname')
仅当存储帐户位于不同的订阅和/或资源组中时,才需要subscriptionid和resourcegroupname