Azure / azure-quickstart-templates

Azure Quickstart Templates
https://aka.ms/azqst
MIT License
14.09k stars 16.14k forks source link

Update subnets with Incremental Deployment #7723

Open deny619 opened 4 years ago

deny619 commented 4 years ago

I'm trying to update subnets with below ARM code to update it's private endpoint policy, enable service endpoint and delegate subnet to a service in Incremental mode. However when I run it, it remove the NSG/UDR on the subnets, I'm afraid it is also changing other subnet settings to their default value. How can I deploy this via ARM by only changing the specified configuration.

    {
        "apiVersion": "2017-05-10",
        "name": "updatePrivateEndpointSubnet",
        "type": "Microsoft.Resources/deployments",
        "resourceGroup": "[parameters('vnetRG')]",
        "properties": {
            "mode": "Incremental",
            "template": {
                "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
                "contentVersion": "1.0.0.0",
                "resources": [
                    {
                        "name": "[concat(parameters('vnetName'), '/', parameters('privateEndpointSubnet'))]",
                        "id": "[resourceId(parameters('vnetRG'), 'Microsoft.Network/virtualNetworks/subnets', parameters('vnetName'), parameters('privateEndpointSubnet'))]",
                        "properties": {
                            "addressPrefix": "[parameters('privateEndpointSubnetAddressPrefix')]",
                            "privateEndpointNetworkPolicies": "Disabled",
                            "privateLinkServiceNetworkPolicies": "Enabled"
                        },
                        "type": "Microsoft.Network/virtualNetworks/subnets",
                        "apiVersion": "2019-09-01"
                    }
                ]
            }
        }
    },
    {
        "apiVersion": "2017-05-10",
        "name": "updateVnetIntegrationSubnet",
        "type": "Microsoft.Resources/deployments",
        "resourceGroup": "[parameters('vnetRG')]",
        "properties": {
            "mode": "Incremental",
            "template": {
                "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
                "contentVersion": "1.0.0.0",
                "resources": [
                    {
                        "name": "[concat(parameters('vnetName'), '/', parameters('vnetIntegrationSubnet'))]",
                        "id": "[resourceId(parameters('vnetRG'), 'Microsoft.Network/virtualNetworks/subnets', parameters('vnetName'), parameters('vnetIntegrationSubnet'))]",
                        "properties": {
                            "addressPrefix": "[parameters('vnetIntegrationSubnetAddressPrefix')]",
                        "serviceEndpoints": [
                            {
                                "service": "Microsoft.Storage"

                            }
                        ],
                        "delegations": [
                            {
                                "name": "0",                                
                                "properties": {
                                    "serviceName": "Microsoft.Web/serverfarms"
                                }
                            }
                        ],                              
                            "privateEndpointNetworkPolicies": "Enabled",
                            "privateLinkServiceNetworkPolicies": "Enabled"
                        },
                        "type": "Microsoft.Network/virtualNetworks/subnets",
                        "apiVersion": "2019-09-01"
                    }
                ]
            }
        }
    },
SamirFarhat commented 4 years ago

Do you have any update ? We are facing the same challenge. Do you find a way to import the Subnet settings ?

niravcybage commented 4 years ago

We are also facing the similar issue.

enterpriseSoftware commented 3 years ago

I'm having a similar issue. Does your issue allow the template to run once successfully but subsequent deployments fail?