Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
311 views
in Technique[技术] by (71.8m points)

azure - Nested Arm Template with with multiple scopes

Can anyone assist me with the issue I am having when I am trying to deploy multiple resources via Arm templates? Since I have resources which are scoped on different levels, I am using nested Arm template deployment. I am trying to create new resource group which is scoped on subscription level and two resources, namely: Log Analytics workspace and Azure Sentinel which are scoped on resource group level. But when I run Powershell command New-AzSubscriptionDeployment I am getting an error, which is stated below:

New-AzDeployment: 3:20:48 PM - Error: Code=InvalidTemplate; Message=Deployment template validation failed: 'The resource 'Microsoft.Resources/resourceGroups/duo' is not defined in the template. Please see https://aka.ms/arm-template for usage details.'. New-AzDeployment: The deployment validation failed

My template is included below. I would really appreciate anyone’s help.

{
    "$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "resourceGroupName": {
            "type": "string",
            "metadata": {
                "description": "Name of resource group."
            }
        },
        "resourceGroupLocation": {
            "type": "string",
            "metadata": {
                "description": "Location of resource group."
            }
        },
        "workspaceNamePrefix": {
            "type": "string",
            "metadata": {
                "description": "Prefix used for naming Log Analytics workspace."
            }   
        
        },
        "azureSentinelSolutionNamePrefix": {
            "type": "string",
            "metadata": {
                "description": "Prefix used for naming Sentinel Solution."
            }
        }        
    },
    "variables": {
        "workspaceName": "[concat(parameters('workspaceNamePrefix'), uniqueString(subscription().id, parameters('resourceGroupName')))]",
        "azureSentinelSolutionName": "[concat(parameters('azureSentinelSolutionNamePrefix'), variables('workspaceName'))]",
        
        "product": "OMSGallery/SecurityInsights",
        "publisher": "Microsoft"
    },
    "resources": [
        {
            "type": "Microsoft.Resources/resourceGroups",
            "apiVersion": "2020-06-01",
            "location": "[parameters('resourceGroupLocation')]",
            "name": "[parameters('resourceGroupName')]",
            "properties": {}
        },
        {
            "type": "Microsoft.Resources/deployments",
            "apiVersion": "2020-06-01",
            "name": "NestedTemplate",
            "resourceGroup": "[parameters('resourceGroupName')]",
            "dependsOn": [
                "[resourceId('Microsoft.Resources/resourceGroups', parameters('resourceGroupName'))]"
            ],
            "properties": {
                "expressionEvaluationOptions": {
                    "scope": "outer"
                },
                "mode": "Incremental",
                "template": {  
                    "$schema": "https://schema.management.azure.com/schemas/2019-08-01/deploymentTemplate.json#",
                    "contentVersion": "1.0.0.0",
                    "parameters": {
                    },
                    "Variables": {},
                    "resources": [
                        {
                            "type": "Microsoft.OperationalInsights/workspaces",
                            "apiVersion": "2020-08-01",
                            "name": "[variables('workspaceName')]",
                            "location": "[parameters('resourceGroupLocation')]",
                            "sku": {
                                "name": "pergb2018"
                                },   
                            "dependsOn": [
                                "[resourceId('Microsoft.Resources/resourceGroups', parameters('resourceGroupName'))]"
                            ]    
                        
                        },
                        {
                    
                            "type": "Microsoft.OperationsManagement/solutions",
                            "apiVersion": "2015-11-01-preview",
                            "name": "[variables('azureSentinelSolutionName')]",
                            "location": "[parameters('resourceGroupLocation')]",
                            "plan": {                                                                                                                                
                                "name": "[variables('azureSentinelSolutionName')]",
                                "promotionCode": "",
                                "product": "[variables('product')]",
                                "publisher": "[variables('publisher')]"
                            },
                            "dependsOn": [
                                "[resourceId('Microsoft.OperationalInsights/workspaces', variables('workspaceName'))]",
                                "[resourceId('Microsoft.Resources/resourceGroups', parameters('resourceGroupName'))]"
                            ],
                            "properties": {
                                "workspaceResourceId": "[resourceId('Microsoft.OperationalInsights/workspaces', variables('workspaceName'))]"
                            }
                                                    
                        }    
                    ],     
                    "outputs": {}
                }
            }
        }   
    ],   
    "outputs": {}
}
question from:https://stackoverflow.com/questions/65835415/nested-arm-template-with-with-multiple-scopes

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...