【发布时间】:2016-03-03 08:32:06
【问题描述】:
鉴于 AzureRM 模板中的以下资源,如何对 commandToExecute 部分中的单引号进行编码?
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[concat(variables('vmNameMaster'), copyIndex(), '/sethost')]",
"apiVersion": "2015-06-15",
"location": "[resourceGroup().location]",
"copy": {
"name": "extensionLoopNode",
"count": "[variables('masterCount')]"
},
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', variables('vmNameMaster'), copyIndex(),'/extensions/DockerExtension')]"
],
"properties": {
"publisher": "Microsoft.OSTCExtensions",
"type": "CustomScriptForLinux",
"typeHandlerVersion": "1.4",
"settings": {
"fileUris": [ ],
"commandToExecute": "[concat('/bin/bash -c \'echo \"export DOCKER_HOST=:2375\" >> /home/', parameters('adminUsername') ,'/.profile\'')]",
"timestamp": 123456789
}
}
},
【问题讨论】:
-
你试过用\转义吗?即 "commandToExecute": "[concat('/bin/bash -c \'echo \"export DOCKER_HOST=:2375\" >> /home/\', parameters(\'adminUsername\') ,\'/.profile \'')]"
标签: azure azure-resource-manager