pulumi / pulumi-azure-native

Azure Native Provider
Apache License 2.0
126 stars 34 forks source link

Creating an Azure Workbook fails on `pulumi up` #926

Closed JRo-connyun closed 2 years ago

JRo-connyun commented 3 years ago

Creating an Azure Workbook fails on pulumi up, including subsequent calls to pulumi up. The workaround described in https://github.com/pulumi/pulumi-azure-native/issues/876#issuecomment-848713884 resolves the problem client side, but seems unsuited for deployment automation.

Steps to reproduce

  1. Configure remote state on Azure Blob Storage with pulumi login azblob://<container-url>
  2. Create new pulumi project from Azure-C# template with pulumi new azure-csharp
  3. Use the following stack:
    
    using Pulumi;
    using Pulumi.AzureNative.Insights;
    using Pulumi.AzureNative.Resources;

class MyStack : Stack { public MyStack() { var resourceGroup = new ResourceGroup("myResourceGroup", new ResourceGroupArgs { ResourceGroupName = "my-resource-group" }); var myWorkbook = new Workbook("myWorkbook", new WorkbookArgs { Category = "workbook", DisplayName = "My workbook", Kind = "shared", ResourceGroupName = resourceGroup.Name, ResourceName = "c0deea5e-3344-40f2-96f8-6f8e1c3b5722", SerializedData = "{\"version\":\"Notebook/1.0\",\"items\":[{\"type\":1,\"content\":{\"json\":\"Hello, World!\"},\"name\":\"text - 0\"}],\"isLocked\":true,\"fallbackResourceIds\":[\"Azure Monitor\"]}", SourceId = "azure monitor", Type = "microsoft.insights/workbooks" } ); } }

4. Deploy the stack using `pulumi up`

Expected:
`pulumi up` succeeds.

Actual:
`pulumi up` fails with:
```text
Diagnostics:
  pulumi:pulumi:Stack (workbook-test-dev):
    System.InvalidOperationException: Expected System.Collections.Immutable.ImmutableDictionary`2[[System.String, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Object, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]] but got System.String deserializing Pulumi.AzureNative.Insights.Workbook.etag
       at Pulumi.Serialization.Converter.ConvertObject(String context, Object val, Type targetType)
       at Pulumi.Serialization.Converter.ConvertValue(String context, Value value, Type targetType, ImmutableHashSet`1 resources)
       at Pulumi.Deployment.CompleteResourceAsync(Resource resource, Boolean remote, Func`2 newDependency, ResourceArgs args, ResourceOptions options, ImmutableDictionary`2 completionSources)
       at Pulumi.Deployment.Runner.<>c__DisplayClass9_0.<<WhileRunningAsync>g__HandleCompletion|0>d.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at Pulumi.Deployment.Runner.WhileRunningAsync()
mikhailshilkov commented 3 years ago

Hi @JRo-connyun thank you for reporting

The Open API spec upstream seems to be wrong here, I filed https://github.com/Azure/azure-rest-api-specs/issues/14874

Meanwhile, we should re-evaluate whether such cases should lead to a panic. I filed https://github.com/pulumi/pulumi/issues/7329 to track that.

JRo-connyun commented 3 years ago

Hi @mikhailshilkov,

thanks for the quick response and the links to the upstream tickets! We will follow up on this.

mikhailshilkov commented 2 years ago

The underlying issue in the .NET SDK was fixed in pulumi 3.17.0 and shipped in azure-native 1.45.0. Even if data types don't match, there will be no exception thrown by Pulumi. I'll go ahead and close this.