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

WindowsFunctionApp with existing AppServicePlans #1922

Open
ranjeetkpGit opened this issue Mar 29, 2024 · 13 comments
Open

WindowsFunctionApp with existing AppServicePlans #1922

ranjeetkpGit opened this issue Mar 29, 2024 · 13 comments
Labels
awaiting-feedback kind/enhancement Improvements or new features

Comments

@ranjeetkpGit
Copy link

ranjeetkpGit commented Mar 29, 2024

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.

image

@ranjeetkpGit ranjeetkpGit added kind/enhancement Improvements or new features needs-triage Needs attention from the triage team labels Mar 29, 2024
@danielrbradley
Copy link
Member

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.

@danielrbradley danielrbradley added awaiting-feedback and removed needs-triage Needs attention from the triage team labels Apr 2, 2024
@ranjeetkpGit
Copy link
Author

ranjeetkpGit commented Apr 2, 2024

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;
        }

image

If a function app with same name created with FunctionApp (classic) already exists WindowsFunctionApp gives following error
image

@mikhailshilkov mikhailshilkov added needs-triage Needs attention from the triage team and removed awaiting-feedback labels Apr 17, 2024
@thomas11
Copy link
Contributor

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?

@thomas11 thomas11 added awaiting-feedback and removed needs-triage Needs attention from the triage team labels Apr 17, 2024
@ranjeetkpGit
Copy link
Author

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?

@pulumi-bot pulumi-bot added the needs-triage Needs attention from the triage team label Apr 22, 2024
@thomas11
Copy link
Contributor

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 thomas11 removed the needs-triage Needs attention from the triage team label Apr 23, 2024
@ranjeetkpGit
Copy link
Author

ranjeetkpGit commented Apr 23, 2024

@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

@thomas11
Copy link
Contributor

thomas11 commented Apr 23, 2024

I see. Could you try upgrading Azure Classic to v5.72.0? Or is there an issue preventing that?

@ranjeetkpGit
Copy link
Author

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
image

@thomas11
Copy link
Contributor

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.

@pierskarsenbarg
Copy link
Member

@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: #1879

which as guin pointed out is linked to this issue: hashicorp/terraform-provider-azurerm#19600

which has been closed as stale.

@mikhailshilkov mikhailshilkov added needs-triage Needs attention from the triage team and removed awaiting-feedback labels May 8, 2024
@thomas11
Copy link
Contributor

@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.

@pierskarsenbarg
Copy link
Member

I've got the code for it... let me put a repo together that you can just clone and work with

@pierskarsenbarg
Copy link
Member

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

@thomas11 thomas11 added awaiting-feedback and removed needs-triage Needs attention from the triage team labels May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-feedback kind/enhancement Improvements or new features
Projects
None yet
Development

No branches or pull requests

6 participants