pulumi-azure-native icon indicating copy to clipboard operation
pulumi-azure-native copied to clipboard

Second usage of ListWebAppPublishingCredentials throws error in preview

Open Jonne opened this issue 3 years ago • 6 comments

What happened?

I've added a second web app to my stack and try to invoke listWebAppPublishingCredentials so I can return the publishing in credentials in the output. Running the preview of the upgrade results in the following error:

    error: Running program 'C:\repos\pulumibug\bin\Debug\netcoreapp3.1\pulumibug.dll' failed with an unhandled exception:
    Grpc.Core.RpcException: Status(StatusCode="Unknown", Detail="invocation of azure-native:web:listWebAppPublishingCredentials returned an error: request failed /subscriptions/d0ca5bfc-202d-49af-99c1-6f9da0fdac3b/resourceGroups/rg241acfec/providers/Microsoft.Web/sites/services2055eeadc/config/publishingcredentials/list: autorest/azure: Service returned an error. Status=404 Code="ResourceNotFound" Message="The Resource 'Microsoft.Web/sites/services2055eeadc' under resource group 'rg241acfec' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix"")
       at async Task<InvokeResponse> Pulumi.GrpcMonitor.InvokeAsync(InvokeRequest request)
       at async Task<SerializationResult> Pulumi.Deployment.InvokeRawAsync(string token, SerializationResult argsSerializationResult, InvokeOptions options)
       at async Task<OutputData<T>> Pulumi.Deployment.RawInvoke<T>(string token, InvokeArgs args, InvokeOptions options)
       at async Task<OutputData<U>> Pulumi.Output<T>.ApplyHelperAsync<U>(Task<OutputData<T>> dataTask, Func<T, Output<U>> func)

This only happens during an upgrade. If I destroy the stack and re-recreate it, it works.

Steps to reproduce

First create a new stack with a single web app:

using Pulumi;
using Pulumi.AzureNative.Resources;
using Pulumi.AzureNative.Web;
using Pulumi.AzureNative.Web.Inputs;

class MyStack : Stack
{
    public MyStack()
    {
        // Add your resources here
        var resourceGroup = new ResourceGroup($"rg");
        
        var appServicePlan = new Pulumi.AzureNative.Web.AppServicePlan("asp", new AppServicePlanArgs
        {
            ResourceGroupName = resourceGroup.Name,
            Kind = "App",
            Sku = new SkuDescriptionArgs
            {
                Name = "B1",
                Tier = "Basic"
            }
        });
        
        var app = new WebApp("services", new WebAppArgs
        {
            ResourceGroupName = resourceGroup.Name,
            ServerFarmId = appServicePlan.Id,
        });

        var credentials = ListWebAppPublishingCredentials.Invoke(new ListWebAppPublishingCredentialsInvokeArgs
        {
            Name = app.Name,
            ResourceGroupName = resourceGroup.Name
        });

        PublishingUserName = credentials.Apply(c => c.PublishingUserName!);
        PublishingPassword = credentials.Apply(c => c.PublishingPassword!);
    }
    
    [Output]
    public Output<string> PublishingUserName { get; set; }

    [Output]
    public Output<string> PublishingPassword { get; set; }
}

Then run pulumi up and confirm the creation.

Secondly, add a second web app:

class MyStack : Stack
{
    public MyStack()
    {
        // Add your resources here
        var resourceGroup = new ResourceGroup($"rg");
        
        var appServicePlan = new Pulumi.AzureNative.Web.AppServicePlan("asp", new AppServicePlanArgs
        {
            ResourceGroupName = resourceGroup.Name,
            Kind = "App",
            Sku = new SkuDescriptionArgs
            {
                Name = "B1",
                Tier = "Basic"
            }
        });
        
        var app = new WebApp("services", new WebAppArgs
        {
            ResourceGroupName = resourceGroup.Name,
            ServerFarmId = appServicePlan.Id,
        });

        var credentials = ListWebAppPublishingCredentials.Invoke(new ListWebAppPublishingCredentialsInvokeArgs
        {
            Name = app.Name,
            ResourceGroupName = resourceGroup.Name
        });

        PublishingUserName = credentials.Apply(c => c.PublishingUserName!);
        PublishingPassword = credentials.Apply(c => c.PublishingPassword!);
        
        var appServicePlan2 = new Pulumi.AzureNative.Web.AppServicePlan("asp2", new AppServicePlanArgs
        {
            ResourceGroupName = resourceGroup.Name,
            Kind = "App",
            Sku = new SkuDescriptionArgs
            {
                Name = "B1",
                Tier = "Basic"
            }
        });
        
        var app2 = new WebApp("services2", new WebAppArgs
        {
            ResourceGroupName = resourceGroup.Name,
            ServerFarmId = appServicePlan2.Id,
        });

        var credentials2 = ListWebAppPublishingCredentials.Invoke(new ListWebAppPublishingCredentialsInvokeArgs
        {
            Name = app2.Name,
            ResourceGroupName = resourceGroup.Name
        });

        PublishingUserName2 = credentials2.Apply(c => c.PublishingUserName!);
        PublishingPassword2 = credentials2.Apply(c => c.PublishingPassword!);
    }
        
    [Output]
    public Output<string> PublishingUserName { get; set; }

    [Output]
    public Output<string> PublishingPassword { get; set; }
            
    [Output]
    public Output<string> PublishingUserName2 { get; set; }

    [Output]
    public Output<string> PublishingPassword2 { get; set; }
}

Expected Behavior

I would expect the second web app to be created and the second publishing credentials to be returned in the output.

Actual Behavior

A resource not found exception is thrown.

Versions used

CLI Version 3.28.0 Go Version go1.17.8 Go Compiler gc

Plugins NAME VERSION azure-native 1.62.0 dotnet unknown

Host OS Microsoft Windows 10 Pro Version 10.0.19043 Build 19043 Arch x86_64

This project is written in dotnet (C:\Program Files\dotnet\dotnet.exe v6.0.100)

Current Stack: dev

TYPE URN pulumi:pulumi:Stack urn:pulumi:dev::pulumibug::pulumi:pulumi:Stack::pulumibug-dev pulumi:providers:azure-native urn:pulumi:dev::pulumibug::pulumi:providers:azure-native::default_1_62_0 azure-native:resources:ResourceGroup urn:pulumi:dev::pulumibug::azure-native:resources:ResourceGroup::rg azure-native:web:AppServicePlan urn:pulumi:dev::pulumibug::azure-native:web:AppServicePlan::asp azure-native:web:WebApp urn:pulumi:dev::pulumibug::azure-native:web:WebApp::services

Found no pending operations associated with dev

Backend Name pulumi.com URL https://app.pulumi.com/jonne User jonne Organizations jonne

NAME VERSION Pulumi 3.28.0 Pulumi.AzureNative 1.62.0

Pulumi locates its logs in C:\Users\jonne\AppData\Local\Temp by default

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

Jonne avatar Apr 12 '22 12:04 Jonne

Hi @Jonne - thank you for letting us know. We'll take a look as soon as we can.

guineveresaenger avatar Apr 18 '22 19:04 guineveresaenger

We're seeing this as well. @Jonne given a substantial amount of time has gone by - did you find a way to work around it?

khellang avatar Oct 28 '22 11:10 khellang

Also, is this related to https://github.com/pulumi/pulumi/issues/9593?

khellang avatar Oct 28 '22 11:10 khellang

Update on this please. This is a significant bug (violates how outputs are supposed to work) that impacts use of functions.

Christoba avatar Mar 24 '23 20:03 Christoba

Indeed, this is blocked on https://github.com/pulumi/pulumi/issues/9593

mikhailshilkov avatar Sep 12 '23 12:09 mikhailshilkov

It looks like the underlying issue (https://github.com/pulumi/pulumi/issues/9593) has been fixed, is anyone still observing this issue in recent versions of the provider?

mjeffryes avatar Jun 17 '25 00:06 mjeffryes