blueprint vNet artifact failed to be updated when there is a VM in it

FENG CHEN 21 Reputation points
2021-08-21T12:02:37.627+00:00

I am working on a blueprint to create a baseline configuration on new subscription. It will deploy a few vnets using template artifacts and the artifacts works and I can rerun the blueprint repeatedly.

But as soon as I create a VM in a vNet, the whole blueprint will fail to update, even when vNet artifact is not changed.

When I run
Set-AzBlueprintAssignment -Name "${blueprintName}_assignment" -AssignmentFile .\${blueprintName}\assign.json

It will fail with error :

The artifact 'prodvnet' of type 'Template' failed to deploy due to the following error: Template deployment failed with error [ { "code": "InUseSubnetCannotBeDeleted", "message": "Subnet sub-private is in use by /subscriptions/xxxxxxxxx/resourceGroups/rg-prodvm/providers/Microsoft.Network/networkInterfaces/prodvm2750/ipConfigurations/ipconfig1 and cannot be deleted. In order to delete the subnet, delete all the resources within the subnet. See aka.ms/deletesubnet." } ]

I have to delete the VM, then I can reassign the blueprint and it will work again.

This means I can't use blueprint to constantly update my environment as soon as I have VM deployed.

Is there any workaround for this problem? I tried to find some documents for blueprint template artifacts, see if there is a forced "increamental" deployment mode, but didn't find it.

Thanks,
Jack

Azure Blueprints
Azure Blueprints
An Azure service that provides templates for quick, repeatable creation of fully governed cloud subscriptions.
72 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. FENG CHEN 21 Reputation points
    2021-08-21T13:17:59.767+00:00

    OK I see this is more a vNet ARM issue, not blueprint particularly.

    It's the same issue https://github.com/Azure/azure-quickstart-templates/issues/2786

    When vNet is redeployed, even with incremental mode, it will delete/recreate subnet.

    A conditional deployment might be a workaround, but it kind of sucks.

    I have tried blueprint and I am disappointed, it looks good on paper, but when you really try to use it, there are lots of problems make it not really usable as it's supposed to.

    For example, many functions will not work in blueprint artifacts when they are working in ARM templates.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.