I'm trying to use the resourceid() function instead of concat() for the Microsoft.Web/connections api id property.
If I use the concat like this, it works:
{
"type": "Microsoft.Web/connections",
"apiVersion": "2016-06-01",
"name": "[parameters('Office365_ConnectionName')]",
"location": "[parameters('logicApp_Location')]",
"kind": "V1",
"properties": {
"displayName": "[parameters('Office365_ConnectionDisplayName')]",
"customParameterValues": {},
"api": {
"id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', parameters('logicApp_Location'), '/managedApis/', 'office365')]"
}
}
}
If I try to use resourceid() I get a bad request:
{
"type": "Microsoft.Web/connections",
"apiVersion": "2016-06-01",
"name": "[parameters('Office365_ConnectionName')]",
"location": "[parameters('logicApp_Location')]",
"kind": "V1",
"properties": {
"displayName": "[parameters('Office365_ConnectionDisplayName')]",
"customParameterValues": {},
"api": {
"id": "[resourceId('Microsoft.Web/locations/managedApis', parameters('logicApp_Location'), 'office365')]"
}
}
}
InvalidRequestContent: The request content is not valid and could not be deserialized: 'The 'id' property '/subscriptions/xxxx/resourceGroups/xxxxx/providers/Microsoft.Web/locations/westeurope/managedApis/office365' under 'properties.api' is not valid.'
Am I using the resourceid() function properly?
CodePudding user response:
After reproducing the issue from my end, I have observed that you are receiving this because you are using the resourceId() function, which returns the Id of a single resource which do not have any defined level where the template is getting deployed to.
Returns the unique identifier of a resource. You use this function when the resource name is ambiguous or not provisioned within the same template. The format of the returned identifier varies based on whether the deployment happens at the scope of a resource group, subscription, management group, or tenant.
whereas the subscriptionResourceId() function, which obtains the ID for a resource deployed at the subscription level which is actually needed to be included in properties.api.
Returns the unique identifier for a resource deployed at the subscription level.
In your case below will be the template
{
"type": "Microsoft.Web/connections",
"apiVersion": "2016-06-01",
"name": "[parameters('Office365_ConnectionName')]",
"location": "[parameters('logicApp_Location')]",
"kind": "V1",
"properties": {
"displayName": "[parameters('Office365_ConnectionDisplayName')]",
"customParameterValues": {},
"api": {
"id": "[subscriptionResourceId('Microsoft.Web/locations/managedApis', parameters('logicApp_Location'), 'office365')]"
}
}
}
Results when when resourceId() function is used
Results when when subscriptionResourceId() function is used
REFERENCES: Template functions - MSFT Docs