我有有條件創建資源的ARM模板:臂模板條件的輸出參數
{
"type": "Microsoft.Storage/storageAccounts",
"sku": {
"name": "Standard_GRS",
"tier": "Standard"
},
"kind": "BlobStorage",
"name": "[variables('storageAccounts_name')]",
"condition": "[equals(parameters('is_Not_Development'), 'True')]",
"apiVersion": "2017-06-01",
"location": "[resourceGroup().location]",
"scale": null,
"properties": {
"accessTier": "Hot"
},
"dependsOn": []
},
在我的輸出參數我這會導致如果不創建資源的錯誤如下:
"storageAccountConnectionString": {
"type": "string",
"value": "[Concat('DefaultEndpointsProtocol=https;AccountName=',variables('StorageAccounts_name'),';AccountKey=',listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('StorageAccounts_name')), providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).keys[0].value)]"
},
我已經試過這樣:
"storageAccountConnectionString": {
"type": "string",
"condition": "[equals(parameters('is_Not_Development'), 'True')]",
"value": "[Concat('DefaultEndpointsProtocol=https;AccountName=',variables('StorageAccounts_name'),';AccountKey=',listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('StorageAccounts_name')), providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).keys[0].value)]"
},
與條件條款,但這不是recogni SED。我怎樣才能使輸出參數有條件?
UPDATE:
我曾嘗試以下:
"storageAccountConnectionString": {
"type": "string",
"value": "[if(equals(parameters('is_Not_Development'),'False'),'null',Concat('DefaultEndpointsProtocol=https;AccountName=',variables('StorageAccounts_name'),';AccountKey=',listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('StorageAccounts_name')), providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).keys[0].value))]"
},
,但它給了我同樣的錯誤信息,則必須評估真假兩條件。
我在Azure ARM模板中使用IF語句的經驗非常糟糕。 (請參閱https://stackoverflow.com/questions/45923848/can-i-have-an-arm-template-resource-with-a-copy-array-of-0-to-n)。基本上,IF的雙方(真/假)得到評估。目前沒有辦法解決我發現的這個問題。 –
我爲此添加了一個Azure UserVoice項目:https://feedback.azure.com/forums/34192--general-feedback/suggestions/31538470-arm-template-if-function-should-not-evaluate-both –
Here's解決此問題的功能請求:https://feedback.azure.com/forums/281804-azure-resource-manager/suggestions/19492006-conditional-output-from-arm-template – jschmitter