-3

I'm trying to execute automated script generated from Azure for iothub end points, but getting the following the error:

New-AzureRmResourceGroupDeployment : 12:25:25 AM - Error: 
Code=InvalidTemplate; Message=Deployment template validation failed: 'The 
template resource 'ServiceBus1/Topic1/iothubroutes_tst-IOTHUB' at line '216' 
and column '10' is not valid: Unable to evaluate template language function 
'resourceId': function requires exactly one multi-segmented argument which 
must be resource type including resource provider namespace. Current function 
arguments 'Microsoft.ServiceBus/namespaces/topics,ServiceBus1/Topic1'. Please 
see https://aka.ms/arm-template-expressions/#resourceid for usage details.. 
Please see https://aka.ms/arm-template-expressions for usage details.'.
At C:\Users\user\Desktop\testEndpoints\CIMS-ResourceGrp\deplo
y.ps1:104 char:5
+     New-AzureRmResourceGroupDeployment -ResourceGroupName $resourceGr ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [New-AzureRmResourceGroupDeplo 
   yment], Exception
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets 
   .Implementation.NewAzureResourceGroupDeploymentCmdlet

Please find below is the template file piece of code:

"enableExpress": false
        },
        "dependsOn": [
            "[resourceId('Microsoft.ServiceBus/namespaces', parameters('namespaces_CS_ServiceBus_name'))]"
        ]
    },
    {
        "comments": "Generalized from resource: '/subscriptions/7dshsjdh/resourcegroups/CS-ResourceGrp/providers/Microsoft.ServiceBus/namespaces/CS-ServiceBus/topics/cs-topic/authorizationRules/iothubroutes_Cs-IOTHUB'.",
        "type": "Microsoft.ServiceBus/namespaces/topics/authorizationRules",
        "name": "[parameters('authorizationRules_iothubroutes_CS_IOTHUB_name')]",
        "apiVersion": "2015-08-01",
        "location": "East US",
        "scale": null,
        "properties": {
            "rights": [
                "Send"
            ]
        },
        "dependsOn": [
            "[resourceId('Microsoft.ServiceBus/namespaces', parameters('namespaces_CS_ServiceBus_name'))]",
            "[resourceId('Microsoft.ServiceBus/namespaces/topics', parameters('topics_cs_topic_name'))]"
        ]
Or B
  • 1,857
  • 15
  • 22
Sandeep
  • 7
  • 4

1 Answers1

0

It is not recommended to deploy the ARM template which is generated from Azure portal directly. Because the ARM template which you copied from Azure portal will contains all the resources in the current resource group and parts of your resources can't be exported to the template.

To create an IoT hub using Azure Resource Manager template, I suggest you use the template included in following article.

Create an IoT hub using Azure Resource Manager template (PowerShell)

Amor
  • 8,325
  • 2
  • 19
  • 21