straight-hair-32184
03/18/2025, 7:17 PMapplication_map
== {}
On a subsequent run it's application_map
== { "name0":"dev-webapp-name0-90fh3g","name1":"dev-webapp-name1-516woe", ... }
This is despite the Console.WriteLine($"newdict: {JsonSerializer.Serialize(newdict)}");
command always outputting the "correct" value.
Any ideas? options to overcome this other than manually create N WebApps instead of deriving from an array?
Thanks
Example below
Pulumi.yaml
config:
KEY:names:
- name0
- name1
- name2
- name3
...
var config = new Pulumi.Config("KEY");
var names = config.RequireObject<List<string>>("names");
var appServicePlan = new AppServicePlan(appServicePlanName, new()
{
// Name = appServicePlanName,
Kind = "app",
Location = location,
ResourceGroupName = resourceGroup.Name,
...,
});
var apps = names .ToDictionary(name => name, name => new LinuxDockerWebAppComponent(name,
new LinuxDockerWebAppArgs
{
ResourceGroup = resourceGroup.Name,
AppServicePlanId = appServicePlan .LinuxAppServicePlanId,
SubscriptionId = SubscriptionId,
AppConfig = appConfigConnectionString,
RegistryRg = registry_rg,
RegistryName = registry,
})
);
var newdict = new Dictionary<string, string>();
apps.ToList().ForEach(kv => kv.Value.ResourceName.Apply(v => newdict[kv.Key] = v));
var apps_json = JsonSerializer.Serialize(newdict);
Console.WriteLine($"newdict: {JsonSerializer.Serialize(newdict)}");
List<Pulumi.Resource> dependItems = new List<Pulumi.Resource>();
dependItems.AddRange(apps.Values.ToList());
var appMap= new KeyValue("application_map", new KeyValueArgs
{
KeyValueName = "application_map",
ResourceGroupName = resourceGroup.Name,
ConfigStoreName = appConfig.Name,
Value = apps_json,
ContentType = "application/json"
}, new CustomResourceOptions
{
DependsOn = dependItems,
});
echoing-dinner-19531
03/18/2025, 7:50 PMApply(v => newdict[kv.Key] = v)
is a little suspect because Apply's run inside Tasks asynchronously so that dictionary assignment might not happen when you expect it to.
I don't think this is a dependsOn issue, just async mutation issues.straight-hair-32184
03/18/2025, 7:58 PMConsole.WriteLine($"newdict: {JsonSerializer.Serialize(newdict)}");
coming out correct?
Do you have better suggestions on how to arrive at my goal? I've been trying many things but nothing seems to 100% guarantee all WebApp objects have finalized their state to use in name mapping And DependsOn association.
I'm also doing testing with --parallel 1
for this and other annoyances of too many api calls, which may have to be a temporary workaround.
Edit: it's just name use for that line. Ignore - that is calculated before the resource is even attempted created. Other part of the question still stands though.echoing-dinner-19531
03/19/2025, 7:55 AM<string, Output<string>>
then use Output.JsonSerialize
instead of the normal json serialise so it handles the outputs in it.straight-hair-32184
03/21/2025, 7:11 PM