I have an issue with a ARM template in which I replace a certain part with a template function. This happens during the execution of the release pipeline. The ARM template is installed by a Azure Powershell Script which I added to the release pipeline.
Here is the relevant part throwing the error:
"parameters": {
"connections_office365_externalid": {
"defaultValue": "[concat(resourceGroup().id,'/providers')]/Microsoft.Web/connections/office365",
"type": "String"
},
"connections_sql_externalid": {
"defaultValue": "[concat(resourceGroup().id, '/providers')]/Microsoft.Web/connections/sql25",
"type": "String"
}
},
When it comes to the deployment of the ARM template I get the following error:
> Status Message: Property id '[concat(resourceGroup().id,
> '/providers')]/Microsoft.Web/connections/office365' at path
> 'properties.parameters.$connections.value.office365.connectionId' is
> invalid. Expect fully qualified resource Id that start with
> '/subscriptions/{subscriptionId}' or
> '/providers/{resourceProviderNamespace}/'.
> (Code:LinkedInvalidPropertyId)
It seems that the part with the template function is not executed because the function is not translated into the appropriate value.Does anybody know what could be the issue that this template function is not executed on runtime of the release pipeline?`
UPDATE:
This is how the DefaultValue Part is replaced prior deployment:
I replace a particular part of the string (regex) to have it dynamic
(Get-Content $file.FullName -Raw) -replace "\/subscriptions\/(.*?)\/resourceGroups\/customerPrefix(.*?)\/providers","[concat(resourceGroup().id, '/providers')]" | Set-Content $file.FullName
You just need to change your replacing script a little bit to make it work. See below:
I have tested and found the expression [concat(resourceGroup().id,'/providers')]/Microsoft.Web/connections/office365
cannot be evaluated in the template.
The correct expression should be like below:
"defaultValue": "[concat(resourceGroup().id, '/providers', '/Microsoft.Web/connections/office365')]"
Since you want to replace a particular part of the string (regex) to have it dynamic. You can change your replacing script like:
(Get-Content $file.FullName -Raw) -replace "\/subscriptions\/(.*?)\/resourceGroups\/(.*?)\/providers(\/.*)`"",'[concat(resourceGroup().id, ''/providers'', ''$3'')]"' | Set-Content $file.FullName
Above script will replace relevant string to be like this "[concat(resourceGroup().id, '/providers', '/Microsoft.Web/connections/sql25')]"
,