【发布时间】:2019-12-21 12:25:41
【问题描述】:
我正在尝试使用 ARM 模板部署 Redis 缓存,但它一直失败并出现以下错误:
{"code":"DeploymentFailed","message":"至少一个资源部署 手术失败。请列出部署操作以了解详细信息。 用法请见https://aka.ms/arm-debug 详细信息。","详细信息":[{"code":"BadRequest","message":"{\r\n \"error\": {\r\n \"code\": \"LinkedInvalidPropertyId\",\r\n \"message\": \"路径中的属性 id 'GET-PREREQ-existingDiagnosticsStorageAccountId' “properties.storageAccountId”无效。期待完全合格 以“/subscriptions/{subscriptionId}”开头的资源 ID 或 '/providers/{resourceProviderNamespace}/'.\"\r\n }\r\n}"}]}
在线搜索资源,但我无法弄清楚到底出了什么问题。 Redis 缓存资源确实已创建,但部署并未完全成功。以下似乎失败了: 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"
}
}
}
【问题讨论】:
-
因为错误消息表明
storageAccountId需要是存储帐户的完整resource id,而不是您的参数文件所指示的GET-PREREQ-existingDiagnosticsStorageAccountId
标签: powershell azure-devops arm-template