Way to replace existing strorage account in cloud using biceps

Varma 1,620 Reputation points
2026-05-11T02:15:40.48+00:00

following bicep code: which creates storage account and i am using following deployment command to execute this code:

@description('this is for storage account name')
@minLength(3)
@maxLength(24)
param storageAccount string

@description('this is for location')
param location string = resourceGroup().location

@description('this is for SKU')
param skuforyou string

resource storageAccountt 'Microsoft.Storage/storageAccounts@2023-05-01' = {
  name: storageAccount
  location: location
  sku: {
    name: skuforyou
  }
  kind: 'storageV2'
}


command used:


New-AzResourceGroupDeployment -Name 'testdeployment' -TemplateFile 'I:\Bicep\BicepUdemy\main.bicep' -ResourceGroupName 'RG' -Mode Incremental

my questions are:

  1. why above commands new account every time , ( of course i was giving new storage account name ) every time.
  2. what change should be done to above command only to make it replace instead of adding new one?
Azure Automation
Azure Automation

An Azure service that is used to automate, configure, and install updates across hybrid environments.

0 comments No comments

Answer accepted by question author
Siva shunmugam Nadessin 10,900 Reputation points Microsoft External Staff Moderator
2026-05-11T11:27:41.84+00:00

Hello Varma,

Thank you for reaching out to the Microsoft Q&A forum. 

 When investigated it looks like it’s doing exactly what you’ve told it—every time you hand it a brand-new name, an Incremental deployment will happily create a new storage account rather than touching your old one. If you want to “replace” (delete the old and stand up the new in its place) just by tweaking the command, switch your deployment mode from Incremental to Complete:

New-AzResourceGroupDeployment `
  -Name testdeployment `
  -TemplateFile 'I:\Bicep\BicepUdemy\main.bicep' `
  -ResourceGroupName RG `
  -Mode Complete

What happens with -Mode Complete is:

• Any resource in the resource group that isn’t in your Bicep template (including your old storage account name) gets removed

• Then it creates the resources you define (your “new” storage account)

If your goal is simply to update an existing storage account in-place, you can stick with Incremental but pass the same storageAccount name on each run—ARM/Bicep will then patch any properties you changed rather than spinning up a new account.

Hope that clears it up!

Reference list

Getting started with Bicep: https://learn.microsoft.com/azure/azure-resource-manager/bicep/install

Troubleshoot Bicep file deployments: https://learn.microsoft.com/azure/azure-resource-manager/troubleshooting/quickstart-troubleshoot-bicep-deployment

Storage account resource reference (Bicep): https://learn.microsoft.com/azure/templates/microsoft.storage/storageAccounts?tabs=bicep

Was this answer helpful?

1 person found this answer helpful.

Answer accepted by question author
Stanislav Zhelyazkov 29,826 Reputation points MVP Volunteer Moderator
2026-05-11T05:36:40.44+00:00

Hi,

You have to provide the same storage account name every time. Storage account name is unique value so by giving a different name every time you are creating a new account. There is no replacement option. You can set mode to Complete in the command but that will create new account and delete the old one and any other resource in the resource group.

Please "Accept the answer" if the information helped you. This will help us and others in the community as well.

Was this answer helpful?

1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

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