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

Pulumi Refresh on Function Apps and Web Apps doesn't update AppSettings/Environment Variables #3279

Closed
tap1992 opened this issue May 13, 2024 · 3 comments
Assignees
Labels
awaiting-feedback kind/bug Some behavior is incorrect or out of spec resolution/duplicate This issue is a duplicate of another issue

Comments

@tap1992
Copy link

tap1992 commented May 13, 2024

What happened?

When a function app or Web App's AppSettings (Environment Variables within Azure Portal) are updated via the Azure Portal and then we run a Pulumi Refresh to pull these changes into our Pulumi state, it doesn't detect a difference and therefore doesn't update the state with the changes.

I have alternatively tried moving these configs from AppSettings as NameValuePairArgs to https://www.pulumi.com/registry/packages/azure-native/api-docs/web/webappapplicationsettings/ however, this has a different issue of not being able to input output values from other Pulumi resources (without using things like Output.tuple which then makes any previews useless as it just shows 'Output' rather then what it's going to change.

Example

Create a WebApp using the below code, then manually delete the TestValue from AppSettings/Environment variables via the Azure Portal and then try a Pulumi Refresh to update the state with the deleted value. C# Azure-Native example:

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;

return await Deployment.RunAsync(() => 
{
    var webApp = new AzureNative.Web.WebApp("webApp", new()
    {
        Kind = "functionapp",
        Location = "East US",
        Name = "sitef6141",
        ResourceGroupName = "testrg123",
        ServerFarmId = "/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testrg123/providers/Microsoft.Web/serverfarms/DefaultAsp",
            SiteConfig = new SiteConfigArgs
            {
                AlwaysOn = true,
                AppSettings = new[]
                {
                        new NameValuePairArgs
                        {
                            Name = "FUNCTIONS_EXTENSION_VERSION",
                            Value = "~4"
                        },
                        new NameValuePairArgs
                        {
                            Name = "FUNCTIONS_WORKER_RUNTIME",
                            Value = "dotnet"
                        },
                        new NameValuePairArgs
                        {
                            Name = "TestValue",
                            Value = "testing1234"
                        },
                        new NameValuePairArgs
                        {
                            Name = "Storage:TableName",
                            Value = $"{shortStackName}TodoList"
                        },
                        new NameValuePairArgs
                        {
                            Name = "Storage:AccountName",
                            Value = storageAccountName
                        },
                        new NameValuePairArgs
                        {
                            Name = "Storage:StorageAccountKey",
                            Value = storageKey
                        },
                        new NameValuePairArgs
                        {
                            Name = "Storage:TableStorageUri",
                            Value = $"https://{storageAccountName}.table.core.windows.net/"
                        },
                }
        },
});
});

Output of pulumi about

CLI
Version 3.115.2
Go Version go1.22.2
Go Compiler gc

Host
OS Microsoft Windows 11 Pro
Version 10.0.22631 Build 22631
Arch x86_64

This project is written in dotnet: executable='C:\Program Files\dotnet\dotnet.exe' version='8.0.204'

Current Stack: uk-dev

Found no pending operations associated with uk-dev

Backend
URL azblob://**
User ***
Organizations
Token type personal

Dependencies:
NAME VERSION
Newtonsoft.Json 13.0.3
Pulumi 3.55.1
Pulumi.Azure 5.47.0
Pulumi.AzureNative 2.2.0

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

@tap1992 tap1992 added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels May 13, 2024
@thomas11
Copy link
Contributor

Hi @tap1992, sorry you're running into trouble here. I notice you're using a rather old version of the Azure Native provider (from Aug 1, 2023). In particular, #2968 that was merged in January might affect your problem. Would you be able to upgrade and try again?

If that doesn't help, would you be able to provide verbose logs via pulumi up --logtostderr --logflow -v=9 2> out.txt? The interesting part is the request we send to Azure and the response we get, marked by HTTP Request Begin and HTTP Request End. You might want to redact your subscription id.

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

This looks like the same issue as #1468 (comment)

@thomas11 Double-check me if we can close it as a duplicate.

@thomas11 thomas11 added the resolution/duplicate This issue is a duplicate of another issue label May 24, 2024
@thomas11 thomas11 self-assigned this May 24, 2024
@thomas11
Copy link
Contributor

This issue is about SiteConfig.AppSettings, the other one about SiteConfig.IpSecurityRestrictions, so it's safe to assume it's the same underlying problem regarding SiteConfig. I'll close this one and clean up the other one.

@tap1992, my recommendation to try a later version of the provider still stands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-feedback kind/bug Some behavior is incorrect or out of spec resolution/duplicate This issue is a duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants