在Azure模板中编码的URL

我试图创build一个ARM模板,当我试图在我的父模板中提供一个templateLink时,我遇到了一个问题。

在父模板中,我试图引用将要使用的其他模板文件的列表。 我通过添加下面的JSON对象来做到这一点

{ "apiVersion": "2016-09-01", "name": "linkedTemplate", "type": "Microsoft.Resources/deployments", "properties": { "mode": "Incremental", "templateLink": { "uri": "[concat(variables('baseURL'), 'settings%2Ejson/raw', variables('queryString'))]", "contentVersion": "1.0.0.0" } } } 

我有baseURL是定义为gitlab安装的path

  "baseURL": "https://<URL>/api/v4/projects/2/repository/files/shared_services%2F", 

为了使GitLab API正常工作,需要将文件之后的URL部分作为引用git存储库中文件path的编码URL。 所以,而不是/和。 在URL中需要该节的%2E和%2F。 所以在我的情况下,我试图访问下面的URL

https://whatever.com/api/v4/projects/2/repository/files/shared_services%2Fsettings%2Ejson/raw

但是,当我使用以下命令使用azure CLI工具运行模板时,

 az group deployment validate --debug -g example --template-file parent.json --parameters "@./parameters.json" 

我得到以下错误

无法从“ https://whatever.com/api/v4/projects/2/repository/files/shared_services%2Fsettings.json/raw ”下载部署内容

这似乎是不pipe我尝试,设置%2Ejson不断变成settings.json。 然而,%2F编码的字符通过确定。 所以我不确定是否有任何可以做的事情来维护%2E,而不使用azure CLI工具将其转换为。

据我所知,Azure模板不支持模板中的encore URI。

根据你的情况,你可以select以下的方式。

1.将您的链接模板保存为公共URL,您可以将其保存在GitHub或公共Azure存储帐户上。

2.虽然链接的模板必须是外部可用的,但不需要普遍提供给公众。 您可以将模板添加到只有存储帐户所有者才能访问的私有存储帐户。 然后,创build一个共享访问签名(SAS)令牌,以在部署过程中启用访问。 您将SAS令牌添加到链接模板的URI。

以下示例显示了链接到另一个模板的父模板。 链接的模板通过作为参数传入的SAS令牌进行访问。

 "parameters": { "sasToken": { "type": "securestring" } }, "resources": [ { "apiVersion": "2017-05-10", "name": "linkedTemplate", "type": "Microsoft.Resources/deployments", "properties": { "mode": "incremental", "templateLink": { "uri": "[concat('https://storagecontosotemplates.blob.core.windows.net/templates/helloworld.json', parameters('sasToken'))]", "contentVersion": "1.0.0.0" } } } ], 

有关这方面的更多信息,请参阅此链接 。