Azure Resource Manager template chained functions

强颜欢笑 提交于 2021-02-05 11:30:12

问题


I am trying to remove / from the URL using azure function before assigning to output variable value

"webappStorageUri":{
      "type": "string",
      "value": "[take(reference(resourceId('Microsoft.Storage/storageAccounts', variables('webappStorageName'))).primaryEndpoints.web, length(reference(resourceId('Microsoft.Storage/storageAccounts', variables('webappStorageName'))).primaryEndpoints.web)-1]"
 }

Returned value from length function should be the value for take function. This is not working. I get following error on deployment. I don't get anything out of this error message. Does Azure support chained function execution? Is this is right approach to remove / from the URL?

Error message

[error]Deployment template language expression evaluation failed: 'Unable to parse language expression 'take(reference(resourceId('Microsoft.Storage/storageAccounts', variables('webappStorageName'))).primaryEndpoints.web, length(reference(resourceId('Microsoft.Storage/storageAccounts', variables('webappStorageName'))).primaryEndpoints.web)-1': expected token 'RightParenthesis' and actual 'Integer'.'. Please see https://aka.ms/arm-template-expressions for usage details.

回答1:


I'm not sure what you are trying to achieve, but your function has issues with brackets, and you cannot really substract by appending -1 in a random place.

"[take(reference(variables('webappStorageName')).primaryEndpoints.web,
    sub(length(reference(variables('webappStorageName')).primaryEndpoints.web), 1))]"

line breaks for readability only



来源:https://stackoverflow.com/questions/60273263/azure-resource-manager-template-chained-functions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!