【问题标题】:Error deploying existing App Service using Pulumi.Azure使用 Pulumi.Azure 部署现有应用服务时出错
【发布时间】:2020-11-09 10:58:44
【问题描述】:

当我尝试将现有应用服务部署到 Azure 时,我收到了 2020-10-29T22:27:58.8724283Z I1029 22:27:58.870264 4596 eventsink.go:78] eventSink::Infoerr(<{%reset%}>panic: interface conversion: interface {} is nil, not map[string]interface {} 2020-10-29T22:27:58.8728827Z <{%reset%}>) 2020-10-29T22:27:58.8735984Z I1029 22:27:58.870264 4596 eventsink.go:78] eventSink::Infoerr(<{%reset%}>goroutine 199 [running]: 2020-10-29T22:27:58.8767921Z <{%reset%}>) 2020-10-29T22:27:58.8778359Z I1029 22:27:58.870264 4596 eventsink.go:78] eventSink::Infoerr(<{%reset%}>github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/web.expandAppServiceLogs(0x47f6180, 0xc0013eca00, 0x4, 0x47f6180, 0xc0013eca00, 0x1)

此错误导致我的堆栈无法部署到 Azure。

   var webApi = new AppService(appServiceName, new AppServiceArgs
                {
                    Name = appServiceName,
                    ResourceGroupName = resourceGroupName,
                    Identity = new AppServiceIdentityArgs {Type = "SystemAssigned"},
                    AppServicePlanId = appServicePlanId,
                    AppSettings =
                    {
                        {"WEBSITE_RUN_FROM_PACKAGE", webApiCodeBlob},
                        {"AzureStorage__AccountName", storageAccountName},
                        {"AzureStorage__AccountKey", storageAccountPrimaryAccessKey},
                        {"APPINSIGHTS_INSTRUMENTATIONKEY", appInsightsInstrumentationKey},
                        {
                            "APPLICATIONINSIGHTS_CONNECTION_STRING", appInsightsConnectionString
                        },
                        {"ApplicationInsightsAgent_EXTENSION_VERSION", "~2"}
                    },
                    ConnectionStrings =
                    {
                        new AppServiceConnectionStringArgs
                        {
                            Name = "AzureServiceBusConnectionString",
                            Value = serviceBusConnectionString,
                            Type = "Custom"
                        },
                        new AppServiceConnectionStringArgs
                        {
                            Name = "BlobStorageConnectionString",
                            Value = blobConnectionString,
                            Type = "Custom"
                        },
                        new AppServiceConnectionStringArgs
                        {
                            Name = "MongoConnectionString",
                            Value = cosmosAccountConnectionString,
                            Type = "Custom"
                        }
                    },
                    SiteConfig = new AppServiceSiteConfigArgs
                    {
                        AlwaysOn = true,
                        Cors = new AppServiceSiteConfigCorsArgs
                        {
                            AllowedOrigins = allowedOrigins
                        }
                    },
                    Tags = new InputMap<string>()
                    {
                        {"team", Team},
                        {"product", Product},
                        {"productId", ProductId},
                        {"environment", environment},
                        {"service", ServiceName}
                    },
                });

如果应用服务不存在,它会首次运行。这仅在部署现有应用服务时失败。只有在应用服务中没有定义日志部分时才会发生这种情况。

我正在使用 Pulumi 3.28.0

【问题讨论】:

    标签: azure pulumi


    【解决方案1】:

    我找到了解决此问题的解决方法,它基于此https://github.com/pulumi/pulumi-azure/issues/383#issuecomment-549192628

    看起来当应用服务中没有配置日志部分并且它试图将您的 C# 堆栈转换为 Pulumi 的内部表示时,有一个无法映射的 nil 值,打开链接以查看有关的更准确详细信息根本原因。

    这是我如何使它工作的。

    将日志部分添加到您的 AppService

     Logs = new AppServiceLogsArgs
                        {
                            ApplicationLogs = new AppServiceLogsApplicationLogsArgs
                            {
                                AzureBlobStorage = new AppServiceLogsApplicationLogsAzureBlobStorageArgs
                                {
                                    Level = "Information",
                                    RetentionInDays = 1,
                                    SasUrl = $"${storageAccount.PrimaryBlobEndpoint}{blobSas}"
                                }
                            },
                            HttpLogs = new AppServiceLogsHttpLogsArgs
                            {
                                FileSystem = new AppServiceLogsHttpLogsFileSystemArgs
                                {
                                    RetentionInDays = 1,
                                    RetentionInMb = 100
                                }
                            }
                        },
    

    【讨论】:

      猜你喜欢
      • 2020-05-18
      • 1970-01-01
      • 2021-10-07
      • 1970-01-01
      • 2018-08-21
      • 1970-01-01
      • 1970-01-01
      • 2022-12-09
      • 1970-01-01
      相关资源
      最近更新 更多