无法通过&传递网址在Azure上的ARM模板中

时间:2018-04-13 06:01:04

标签: bash azure blob arm-template

 "variables": {

        "scriptBaseURL": "https://sample.blob.core.windows.net/test/",
        "sasTokenURL": "?st=2018-04-11T14%3A00%3A00Z&se=2020-04-13T14%3A00%3A00Z&sp=r&sv=2017-04-17&sr=c&sig=9bzbHSDFEPds1mrTxCdCgaF7wnRh%2FsX8sQeNnVMucE%3D",
        "filePath": "[concat(variables('scriptBaseURL'), 'test.rpm', variables('sasTokenURL'))]",
        "mongoDBScript": "[concat(variables('scriptBaseURL'), 'install-mongodb-3.4.sh', variables('sasTokenURL'))]",
        "oracleJDKScript": "[concat(variables('scriptBaseURL'), 'install-oracle-jdk-8.sh', variables('sasTokenURL'))]",
        "install-dependencies": "[concat(variables('mongoDBScript'), ',', variables('oracleJDKScript'))]",
        "port1": 8080,
        "port2": 8090

}

{
    "type": "Microsoft.Compute/virtualMachines/extensions",
    "name": "[concat(parameters('virtualMachineName'),'/install-script')]",
    "apiVersion": "[variables('computeApiVersion')]",
    "location": "[variables('location')]",
    "dependsOn": [
        "[concat('Microsoft.Compute/virtualMachines/', parameters('virtualMachineName'))]"
    ],
    "properties": {
        "publisher": "Microsoft.Azure.Extensions",
        "type": "CustomScript",
        "typeHandlerVersion": "2.0",
        "autoUpgradeMinorVersion": true,
        "settings": {
           "fileUris": "[split(variables('install-dependencies'), ',')]",
           "commandToExecute": "[concat('sh install-dependencies.sh', ' ', variables('port1'), ' ', variables('port2'), ' ', variables('filePath'))]"
        }          
    }
}

我在这一行传递变量('filePath') - &gt; “commandToExecute”: “[CONCAT( 'SH install-dependencies.sh', '',变量( 'PORT1'), '',变量( 'PORT2'), '',变量( '文件路径'))]”< / p>

当我将filePath传递给install-dependencies.sh脚本时,我得到以下值作为第三个参数

https://sample.blob.core.windows.net/test/2018-04-03/builds/test.rpm?st=2018-04-11T14%3A00%3A00Z

而不是

https://sample.blob.core.windows.net/test/2018-04-03/builds/test.rpm?st=2018-04-11T14%3A00%3A00Z&se=2020-04-13T14%3A00%3A00Z&sp=r&sv=2017-04-17&sr=c&sig=9bzbHSDFEPds1mrTxCdCgaF7wnRh%2FsX8sQeNnVMucE%3D

如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

我可以使用以下命令解决此问题

       "commandToExecute": "[concat('sh install-dependencies.sh', ' ', variables('port1'), ' ', variables('port2'), ' ', '\"', variables('filePath'), '\"')]"