”类型错误:_internal_init() 获得多个参数值”使用 Pulumi 创建 Azure App Insights 时出错

发布于 2025-01-13 14:07:56 字数 1786 浏览 0 评论 0原文

我想使用 Python 创建 Azure Application Insights 参考

还有这个参考关于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

I wanna create Azure Application Insights with Python with this reference.

And also this reference is about the update of SDK.

I imported a special version with:

from pulumi_azure_native.insights import v20200202preview as insights

My code is:

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',
    
                                      ),
                                      )

with this code I received the error:

__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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

流年里的时光 2025-01-20 14:07:56

这就是您所需要的,请尝试使用适用于 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 的,但在下面的链接中您也可以看到针对 TypeScript 的示例。
https://www.pulumi.com/registry/packages /azure/api-docs/appinsights/insights/

Here is what you need, give a try using the classic library Azure Classic for Pulumi.

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)

This is for python but in the link below you can also see for TypeScript for example.
https://www.pulumi.com/registry/packages/azure/api-docs/appinsights/insights/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文