如何通过REST API创建Azure Application Insights的新实例

山姆7

我想自动为ASP.Net Web应用程序设置Azure Application Insights帐户。

我已经安装了nuget软件包:Install-Package Microsoft.Azure.Insights -Pre现在,我正在看Microsoft.Azure.Management.Insights.InsightsManagementClient

管理现有帐户有很多操作,除了我找不到创建新帐户的操作。

要明确:在https://portal.azure.com上,我可以单击New > Create > Developer Services > Application Insights我该如何在C#中做到这一点?

山姆7

感谢Anastasiapowershell示例,我能够查看powershell cmdlet的实现并弄清楚如何在代码中执行此操作:

// initialize resource management client
var resourceManagement = new ResourceManagementClient(this.Credentials);
resourceManagement.Providers.RegisterAsync("microsoft.insights").Result;

// create identity & parameters for create call
var resourceIdentity = new ResourceIdentity(
    "SomeResourceName", // ResourceName
    "microsoft.insights/components", // ResourceType
    "2014-04-01" // Api Version
);
var parameters = new GenericResource {
    Location = 'centralus'
};

// send call off and hope for the best
var result = this.ManagementContext.ResourceManagement.Resources.CreateOrUpdateAsync(
    "SomeResourceGroupName",
    resourceIdentity,
    parameters,
    CancellationToken.None).Result;

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何在Azure资源组模板中检索Application Insights实例的检测密钥?

Azure Application Insights - 如何根据指标之间的比较创建警报?

如何通过C#创建Azure API管理实例?

如何通过Azure Functions在本地使用Application Insights?

如何从 Azure Application Insights API 中选择多个 CustomDimensions?

使用REST API创建Azure App Insights失败需要ROLE

ILogger如何记录到Azure Application Insights?

如何更改Azure Application Insights的保留期限?

如何通过 postman 调用 REST API 在 Azure 中创建索引?

如何通过api创建Azure虚拟机?(不是经典的,在新的Azure管理门户上的那个)

我如何创建接口Microsoft.Office.Interop.Word.Application的新实例

如何通过rest api在apache nifi中实例化模板

Azure DevOps Rest API-无法创建新的迭代

无法通过Rest API创建Azure锁

如何使用Azure DevOps REST API创建新的构建管道?

通过多个 Azure Application Insights 查询日志

如何创建ImmutableDictionary的新实例?

如何创建结构的新实例

如何动态创建新实例?

使用 ODATA 从 Application Insights REST API 获取最旧的记录

如何通过Rest API触发Azure管道

如何在 Application Insights 中区分来自不同实例 .net 核心应用程序的跟踪

如何在Azure Application Insights中导出性能数据

如何在Azure Application Insights中访问页面视图?

Azure Cli如何为Webapp启用Application Insights

Azure Application Insights如何确定流量峰值来自何处

如何在Azure Application Insights Analytics上做到与众不同

Django rest总是创建新实例

如何使用Azure CLI脚本将Azure Application Insights正确连接到App Service Spring Application?