Skip to content

[Provisioning] Provide general ability to convert any bicep value stuff into a bicep expression #51371

@ArcturusZhang

Description

@ArcturusZhang

When we are using the provisioning libraries to write some expressions, for instance:

var ai = new CognitiveServiceAccount("ai");

var outputTags = new ProvisioningOutput("tags", typeof(string))
{
    Value = ai.Tags["prod"]
};
var connectionString = new ProvisioningOutput("connectionString", typeof(string))
{
    Value = BicepFunction.Interpolate($"Endpoint={ai.Properties.Endpoints["Azure AI Model Inference API"]}")
}

Our current behavior in the library is inconsistent - sometimes, the expression such as ai.Tags["prod"] would evaluate and gives you the final raw value of that expression.
Sometimes, the expression cannot be evaluated and we expect them to produce a bicep expression, such as in the second case.

But we think in a lot of scenarios, the form of the bicep file might also be important, in which despite an expression could evaluate, we still would like them to stay as an expression which evaluates until when it is deploying.

For instance, we could define a dictionary of tags in the first resource

resource a 'Microsoft.Compute/virtualMachines@yyyy-mm-dd' {
  tags = {
    prod: true
  }
}

resource b 'Microsoft.Compute/virtualMachineScaleSets@yyyy-mm-dd' {
  tags = a.tags
}

Therefore the ability to allow you to assert a specific .net invocation would be treated as bicep expressions is important and should be introduced into the provisioning core library as a utility.

Metadata

Metadata

Assignees

Labels

ClientThis issue is related to a non-management packageProvisioning

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions