Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Bicep Expressions don't work in Interpolated strings #48493

Open
eerhardt opened this issue Feb 28, 2025 · 1 comment
Open

[BUG] Bicep Expressions don't work in Interpolated strings #48493

eerhardt opened this issue Feb 28, 2025 · 1 comment
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. Provisioning

Comments

@eerhardt
Copy link
Member

eerhardt commented Feb 28, 2025

Library name and version

Azure.Provisioning

Describe the bug

When trying to use an expression in an interpolated string, the expression doesn't get interpolated correctly.

Expected behavior

The output bicep should look like:

output connectionString string = 'Endpoint=${ai.properties.endpoints['Azure AI Model Inference API']}'

Actual behavior

output connectionString string = 'Endpoint=ai.properties.endpoints[\'Azure AI Model Inference API\']'

Reproduction Steps

using Azure.Provisioning;
using Azure.Provisioning.CognitiveServices;
using Azure.Provisioning.Expressions;

CognitiveServicesAccount ai = new(nameof(ai));

Infrastructure infra = new();
infra.Add(ai);

var inferenceEndpoint = new IndexExpression(
    (BicepExpression)ai.Properties.Endpoints!,
    "Azure AI Model Inference API");
infra.Add(new ProvisioningOutput("connectionString", typeof(string))
{
    Value = BicepFunction.Interpolate($"Endpoint={inferenceEndpoint}")
});

ProvisioningPlan plan = infra.Build();
string bicep = plan.Compile().First().Value;
Console.WriteLine(bicep);

NOTE: If I cast the IndexExpression to a BicepValue<string> explicitly, then it does produce the right bicep.

var inferenceEndpoint = (BicepValue<string>)new IndexExpression(
    (BicepExpression)ai.Properties.Endpoints!,
    "Azure AI Model Inference API");
infra.Add(new ProvisioningOutput("connectionString", typeof(string))
{
    Value = BicepFunction.Interpolate($"Endpoint={inferenceEndpoint}")
});

Environment

cc @tg-msft @m-nash

@github-actions github-actions bot added the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Feb 28, 2025
@jsquire jsquire added Client This issue points to a problem in the data-plane of the library. Provisioning labels Feb 28, 2025
@jsquire
Copy link
Member

jsquire commented Feb 28, 2025

//cc: @m-nash, @tg-msft

@github-actions github-actions bot removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client This issue points to a problem in the data-plane of the library. Provisioning
Projects
None yet
Development

No branches or pull requests

3 participants