pulumi-azure
pulumi-azure copied to clipboard
WindowsFunctionApp with existing AppServicePlans
Hi, We have existing AppServicePlans created with AppServicePlan(Native) and Plan (Classic) components but when referencing them in WindowsFunctionApp, getting following error. WindowsFunctionApp expects 'serverFarms' (We get serverFarms when creating new plans using ServicePlan component) but we get 'serverfarms' from existing AppServicePlans Is there any way we can create WindowsFunctionApp with existing AppServicePlan ? We are using C# and .NET 8 to create Azure resources.
Hi @ranjeetkpGit
Could you expand on how you're getting the value for the resource ID from Pulumi - please share some example Pulumi code if at all possible. It looks like the error you've shared is possibly from within your function app rather that from you Pulumi code.
Some resource id segments are case insensitive, and Azure sometimes returns different casing too. It's possible that the library producing this error is being overly strict, though this should also be fairly easy to work around with a string replacement if in doubt.
Hi @danielrbradley ,
Thanks for reply. I am creating WindowsFunctionApp (Pulumi Classic) as below
private WindowsFunctionApp CreateFunctionResource(string appName, Plan appServicePlan, FunctionSettings functionSettings, InputMap<string> settings = null, int maxScaleOutLimit = 0)
{
var configurations = new InputMap<string>
{
................
................
};
if (settings != null)
{
configurations.AddRange(settings);
}
var funcAppArgs = new WindowsFunctionAppArgs
{
ResourceGroupName = _coreSettings.ResourceGroup,
ServicePlanId = appServicePlan.Id,
Name = appName,
FunctionsExtensionVersion = _coreSettings.Functions.ExtensionVersion, // v4
Identity = new WindowsFunctionAppIdentityArgs
{
Type = "SystemAssigned"
},
StorageAccountName = _storageAccountName,
StorageAccountAccessKey = _storageAccountKey,
AppSettings = configurations,
SiteConfig = new WindowsFunctionAppSiteConfigArgs
{
AlwaysOn = functionSettings.IsDedicatedPlan(),
AppScaleLimit = maxScaleOutLimit,
ApplicationStack = new WindowsFunctionAppSiteConfigApplicationStackArgs
{
DotnetVersion = _coreSettings.Functions.DotnetFrameworkVersion, // v8.0
UseDotnetIsolatedRuntime = true
}
}
};
var functionApp = new WindowsFunctionApp($"{appName}", funcAppArgs);
return functionApp;
}
private Plan CreateAppServicePlan(FunctionSettings functionSettings, string planName)
{
var appServicePlan = new Plan(planName, new PlanArgs
{
Location = _coreSettings.Region,
ResourceGroupName = _coreSettings.ResourceGroup,
Kind = "FunctionApp",
Name = planName,
Sku = new PlanSkuArgs
{
Tier = functionSettings.SkuTier,
Size = functionSettings.SkuName // Consumption Plan
}
});
return appServicePlan;
}
If a function app with same name created with FunctionApp (classic) already exists WindowsFunctionApp gives following error
Hi @ranjeetkpGit! This issue may have been fixed in the latest provider version, see this upstream issue. Could you try upgrading Azure Classic to v5.72.0?
Hi @ranjeetkpGit! This issue may have been fixed in the latest provider version, see this upstream issue. Could you try upgrading Azure Classic to v5.72.0?
Hi @thomas11 Thanks for reply. As FunctionApp (classic) supports till .NET 6 only, Is there any way we can upgrade it to WindowsFunctionApp without deleting existing resources?
Hi @ranjeetkpGit! This issue may have been fixed in the latest provider version, see this upstream issue. Could you try upgrading Azure Classic to v5.72.0?
Hi @thomas11 Thanks for reply. As FunctionApp (classic) supports till .NET 6 only, Is there any way we can upgrade it to WindowsFunctionApp without deleting existing resources?
Hi @ranjeetkpGit, the issue title and your code sample show that you're already using WindowsFunctionApp. Is that not correct?
@thomas11, This code is to upgrade existing FunctionApp (created with FunctionApp (.NET 6)) to .NET 8 using WindowsFunctionApp. Instead of updating existing FunctionApp it shows error given in screenshot
I see. Could you try upgrading Azure Classic to v5.72.0? Or is there an issue preventing that?
In see. Could you try upgrading Azure Classic to v5.72.0? Or is there an issue preventing that? Upgraded Azure classic to v5.73.0 AppServicePlan case issue resolved but getting same issue when upgrading
I'm not familiar with this specific case, but after changing your code from FunctionApp to WindowsFunctionApp, you probably need to run pulumi refresh. This will add the existing app to your Pulumi state.
If that's not sufficient, you'll need to import the app via its Azure id that you can find in the Azure portal.
@thomas11 I've been looking at this as well. I'm using the latest Azure Classic and when you try to import the Plan resource (https://www.pulumi.com/registry/packages/azure/api-docs/appservice/plan) You get this error:
Preview failed: importing /subscriptions/32b9cb2e-69be-4040-80a6-02cd6b2cc5ec/resourceGroups/rg954bd9e9/providers/Microsoft.Web/serverfarms/piers-appservice-plan: ID was missing the `serverFarms` element
Which feels like it's linked to this issue: https://github.com/pulumi/pulumi-azure/issues/1879
which as guin pointed out is linked to this issue: https://github.com/hashicorp/terraform-provider-azurerm/issues/19600
which has been closed as stale.
@pierskarsenbarg do you happen to have a full repro? I think I know how to fix it but cannot verify the fix without a bunch of manual setup.
I've got the code for it... let me put a repo together that you can just clone and work with
I can't replicate this anymore. I'm not sure why. Trying v5.73.0 (which was probably the version I was on when I tried it) as well as v5.68.0 which is what the customer seemed to be on.
Let me go back to the customer and see if this is still an issue
@pierskarsenbarg any update here on whether the customer is still seeing this issue?
closing for now since we can seem to find a program to reproduce