我发现了一个答案,让我在那里的大部分方式;您可以将请求的Uri设置为list(resourceId('Microsoft.Web/sites/config', variables('webSiteName'), 'publishingcredentials'), '2016-08-01').properties.scmUri
。您还需要对路径的其余部分进行协调(例如,/api/triggeredwebjobs/{webjobname}/run
)
上述代码生成的Uri包含基本身份验证凭据,并且在某个时候解析并且用户名和密码从Uri中取出所以它们在Azure门户中不可见,并且身份验证设置为“基本”,并将凭据设置为提取的值。
但是,我的Uri查询字符串追加到最后传递参数到webjob。在部署过程中,查询字符串会变形(问号会转义为%3F
,如果您的参数值中有任何转义字符,它们将会被取消转义。)
我设法解决了这个问题,弥补了URI(不使用scmUri
属性),然后设置authentication
属性,这是一个同级的uri
属性如下所示
"authentication": { "type": "Basic", "username": "[list(resourceId('Microsoft.Web/sites/config', variables('webSiteName'), 'publishingcredentials'), '2016-08-01').properties.publishingUserName]", "password": "[list(resourceId('Microsoft.Web/sites/config', variables('webSiteName'), 'publishingcredentials'), '2016-08-01').properties.publishingPassword]" }