rhythmic-crowd-40243
11/12/2022, 8:06 AMDefaultHostName
to be the value of a JWT based setting. Prior to this requirement, we’re injecting the app settings into the WebApp
resource:
var apiAppService = new WebApp($"{appNamePart}-api-{_stackName}", new WebAppArgs
{
Location = resourceGroup.Location,
ResourceGroupName = resourceGroup.Name,
ServerFarmId = Output.Format($"{appServicePLan}"),
HttpsOnly = true,
SiteConfig = new SiteConfigArgs
{
AppSettings = appSettings,
// 64 Bit not available on "Free" and "Shared" tiers only on "Basic," "Standard" and above.
// Change app service plan to enable
Use32BitWorkerProcess = false,
// az webapp list-runtimes --os-type linux
LinuxFxVersion = "DOTNETCORE|6.0",
MinTlsVersion = SupportedTlsVersions.SupportedTlsVersions_1_2,
FtpsState = FtpsState.FtpsOnly,
// Only support for the Basic and Standard plans disabled for now.
AlwaysOn = true,
VnetRouteAllEnabled = true
},
Identity = new ManagedServiceIdentityArgs
{
Type = ManagedServiceIdentityType.UserAssigned,
UserAssignedIdentities = Helpers.GetManagedIdentity(_managedIdentities[_stackName])
},
Tags = standardTags
});
However, because the DefaultHostname
is a late arriving value, we’ll need to change how we push the app settings using the `WebAppApplicationSettings`:
var appServiceSetting = new WebAppApplicationSettings(
$"{appNamePart}-api-{_stackName}-app-settings-jwt",
new WebAppApplicationSettingsArgs
{
ResourceGroupName = resourceGroup.Name,
Name = apiAppService.Name,
Properties = appSettings.ToInputMap()
},
new CustomResourceOptions
{
Parent = apiAppService,
DependsOn = apiAppService
});
But it appears it’s not as simple as it sounds. SiteConfigArgs.AppSettings
expects the type InputList<NameValuePairArgs>
but WebApplicationSettingsArgs.Properties
expects InputMap<string>
. At first I tried to convert appSettings
to the required input map with an extension method, but haven’t had success. This is my non working attempt:
public static InputMap<string> ToInputMap(this InputList<NameValuePairArgs> inputList)
{
var inputMap = inputList
.Apply(list => Output
.All(list.Select(s => Output.Tuple(s.Name!, s.Value!))))
.Apply(list =>
{
var map = new InputMap<string>();
foreach (var (key, value) in list)
{
map.Add(key, value);
}
return map;
});
return inputMap;
}
The problem with my implementation is the returned result is <Output<InputMap<string>>
instead of the expected InputMap<string>
so I’m wondering, is it possible to convert a InputList
to an InputMap
? Also curious, what’s the reason for the two different types representing app settings between the WebApp
and WebAppApplicationSettings
?