Open
Description
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);