我發現了一個答案,讓我在那裏的大部分方式;您可以將請求的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]" }