" TypeError: _internal_init() got multiple values for argument" error when created Azure App Insights with Pulumi

" TypeError: _internal_init() got multiple values for argument" error when created Azure App Insights with Pulumi

我想用 Python 创建 Azure Application Insights reference

另外这个reference是关于SDK的更新

我导入了一个特殊版本:

from pulumi_azure_native.insights import v20200202preview as insights

我的代码是:

app_insights = insights.Component('app_insights',
                                      args=insights.ComponentArgs(
                                          application_type='web',
                                          kind='web',
                                          flow_type='Bluefield',
                                          ingestion_mode='LogAnalytics',
                                          resource_group_name=resource_group.name,
                                          location=location_name,
                                          resource_name=get_resource_name(
                                              'app-insight'),
                                          tags=tags_group,
                                          workspace_resource_id='/subscriptions/****-***-**-ae8b-****/resourcegroups/rg-dev-gx/providers/microsoft.operationalinsights/workspaces/insight-wkspc-gx',
    
                                      ),
                                      )

使用此代码我收到了错误:

__self__._internal_init(resource_name, opts, **resource_args.__dict__)
TypeError: _internal_init() got multiple values for argument 'resource_name'
error: an unhandled error occurred: Program exited with non-zero exit code: 1

这是您需要的,尝试使用 Pulumi 的经典库 Azure Classic

import pulumi
import pulumi_azure as azure


my_resource_group = azure.core.ResourceGroup("my_resource_group", location="West Europe")
my_analytics_workspace = azure.operationalinsights.AnalyticsWorkspace("my_analytics_workspace",
                                                                           location=my_resource_group.location,
                                                                           resource_group_name=my_resource_group.name,
                                                                           sku="PerGB2018",
                                                                           retention_in_days=30)
my_insights = azure.appinsights.Insights("my_insights",
                                              location=my_resource_group.location,
                                              resource_group_name=my_resource_group.name,
                                              workspace_id=my_analytics_workspace.id,
                                              application_type="web")
pulumi.export("instrumentationKey", my_insights.instrumentation_key)
pulumi.export("appId", my_insights.app_id)

这是针对 python 的,但在下面的 link 中,您还可以看到针对 TypeScript 的示例。 https://www.pulumi.com/registry/packages/azure/api-docs/appinsights/insights/