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] Indexing a BicepDictionary as an output throws KeyNotFoundException #48491

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

Comments

@eerhardt
Copy link
Member

Library name and version

Azure.Provisioning

Describe the bug

In order to generate bicep like the following:

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

The C# code I wanted to write didn't work as expected.

Expected behavior

I expect the repro code to work and generate bicep with an indexer.

Actual behavior

Unhandled exception. System.Collections.Generic.KeyNotFoundException: The given key 'Azure AI Model Inference API' was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at Azure.Provisioning.BicepDictionary`1.get_Item(String key)
   at Program.<Main>$(String[] args) in D:\source\AspireApp6\AspireApp6.AppHost\Program.cs:line 10

Reproduction Steps

Run the following

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

CognitiveServicesAccount ai = new(nameof(ai));

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

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

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

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