Skip to content

Azure.Provisioning: Add BicepFunction.Union() #57192

@m-nash

Description

@m-nash

Problem

BicepFunction in Azure.Provisioning does not expose Bicep's union() built-in function. This is needed for non-destructive updates to existing resources — most commonly, adding a tag to an existing resource group without replacing all existing tags.

Motivating scenario

Adding a tag to an existing resource group without removing existing tags requires union():

resource existingRg 'Microsoft.Resources/resourceGroups@2023-07-01' existing = {
  name: 'my-demo-rg'
}

resource updatedRg 'Microsoft.Resources/resourceGroups@2023-07-01' = {
  name: 'my-demo-rg'
  location: existingRg.location
  tags: union(existingRg.tags, { env: 'prod' })  // merge, don't replace
}

This cannot be expressed today through the Azure.Provisioning API. Users must either accept destructive tag replacement or drop down to raw Bicep.

Proposed API

public static BicepValue<object> Union(params BicepValue<object>[] values);

// Usage
updatedRg.Tags = BicepFunction.Union(existingRg.Tags, new BicepDictionary<string> { ["env"] = "prod" });

Metadata

Metadata

Assignees

No one assigned

    Labels

    ProvisioningProvisioning.CoreThis item is related to the core Azure.Provisioning features

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions