0
votes

I'm trying to create 3 resource groups using ARM template

  1. rg-prod-remserv-digital-onlinesetup-shared
  2. rg-prod-remserv-digital-onlinesetup-gov
  3. rg-prod-remserv-digital-onlinesetup-non-gov

Creating the following resources in each of the respective resource groups,

  1. rg-prod-remserv-digital-onlinesetup-shared

    • An app-service plan, asp-prod-remserv-digital-onlinesetup-shared

    • An application insights resource, ai-prod-remserv-digital-onlinesetup-shared

  2. rg-prod-remserv-digital-onlinesetup-gov

    • An app-service, which uses the app-service plan and application-insights resource from the shared resource group (i.e rg-prod-remserv-digital-onlinesetup-shared)
  3. rg-prod-remserv-digital-onlinesetup-non-gov

    • An app-service, which uses the app-service plan and application-insights resource from the shared resource group (i.e rg-prod-remserv-digital-onlinesetup-shared)

Please advice, How do i create a dependency so that all these are created once while executing my ARM template.

The code is available in the following path,

https://github.com/Manjunath-Jayaram/ARM-MultipleResourceGroups
1
Assuming, the app-services and the app-service-plan are in the same region, it is possible. You can have a look at nested template docs.microsoft.com/en-us/azure/azure-resource-manager/…Thomas
@Thomas Thank you for replying. My app-service and app-service-plan are sitting under different resource groups.Aryan M
Yes but are resource groups are in the same region/datacenter ? I think it is the only restriction which make senseThomas
Yes, they are part of the same region.Aryan M
@Thomas Thank you for sharing the article. Could you please let me know, how will i be able to link the templates which are present in the same solution, rather than linking them from a storage account.Aryan M

1 Answers

0
votes

You could simply use a fully nested template where everything will be deployed in one go or here's another way below


First in the outputs section of the shared template you need to pass names of the appServicePlan and the ApplicationInsights.

"outputs": {
     "appServicePlan ": {
          "type": "string",
          "value": "[parameters('asp-prod-digital-onlinesetup-sharedName')]"
        },
     "applicationInsights":{
     "type":"string",
     "value":"your app insights name"
       }
  }

So in the rg-prod-remserv-digital-onlinesetup-gov and rg-prod-remserv-digital-onlinesetup-non-gov templates under the resources array, use the "dependsOn": [ ] parameter to pass the values of app-service plan and application-insights resource from the shared resource group.

"dependsOn": [
    "[variables('sharedAppServicePlan')]",
    "[variables('sharedApplicationInsights')]",
    "storageLoop",
  ],

After deployment get the values of the outputs from shared template and pass it on. It can be done by "[reference('<name-of-deployment>').outputs.<property-name>.value]"

Read full documentation

Hope it helped. :-)