Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何通过RESTAPI创建Azure Application Insights的新实例_C#_Asp.net_Azure_Azure Application Insights - Fatal编程技术网

C# 如何通过RESTAPI创建Azure Application Insights的新实例

C# 如何通过RESTAPI创建Azure Application Insights的新实例,c#,asp.net,azure,azure-application-insights,C#,Asp.net,Azure,Azure Application Insights,我想为ASP.NETWeb应用程序自动设置Azure Application Insights帐户 我已安装nuget软件包:安装软件包Microsoft.Azure.Insights-Pre 现在我在看 管理现有帐户有很多操作,但我找不到创建新帐户的操作 澄清一下:在上,我可以单击New>Create>Developer Services>Application Insights。如何在c#中做到这一点?以下是Eric Mattingly创建的脚本(您需要安装Azure PowerShell才

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

我已安装nuget软件包:
安装软件包Microsoft.Azure.Insights-Pre
现在我在看

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


澄清一下:在上,我可以单击
New>Create>Developer Services>Application Insights
。如何在c#中做到这一点?

以下是Eric Mattingly创建的脚本(您需要安装Azure PowerShell才能正常工作):

输出:
App Insights Name=erimattestapp
IKey=00000000-0000-0000-0000-00000000
脚本:
cls
##################################################################
#设定值
##################################################################
#如果手动运行,请在首次执行登录Azure门户之前将其注释到
#添加AzureAccount
#设置Application Insights资源的名称
$appInsightsName=“erimatTestApp”
#设置用于标记“AppInsightsApp”值的应用程序名称-http://azure.microsoft.com/en-us/documentation/articles/azure-preview-portal-using-tags/
$applicationTagName=“erimatTestApp”
#设置要使用的资源组的名称。默认情况下,将使用应用程序名称作为启动程序
$resourceGroupName=“erimatTestAppRG”
##################################################################
#创建资源并输出名称和iKey
##################################################################
#将脚本设置为资源管理器-http://azure.microsoft.com/en-us/documentation/articles/powershell-azure-resource-manager/
切换AzureMode AzureResourceManager
#选择azure订阅
选择AzureSubscription-SubscriptionName“ECIT预生产监控”
#创建App Insights资源
$resource=New AzureResource-Name$appInsightsName-ResourceGroupName$ResourceGroupName-Tag@{Name=“AppInsightsApp”;Value=$ApplicationAgName}-ResourceType“Microsoft.Insights/Components”-位置“美国中部”-ApiVersion“2014-08-01”
#允许团队所有者访问-http://azure.microsoft.com/en-us/documentation/articles/role-based-access-control-powershell/
新AzureRoleAssignment-邮件“ECITTelemetryTeam@microsoft.com“-RoleDefinitionName所有者-作用域$resource.ResourceId | Out Null
#显示iKey
写入主机“App Insights Name=“$resource.Properties[“Name”]
写主机“IKey=“$resource.Properties[“InstrumentationKey”]
多亏了的,我能够查看并找出如何在代码中执行此操作:

// 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;

我很困惑。您提到的软件包是Microsoft Azure Insights。在“澄清”中,您提到了Microsoft Application Insights。你想要哪一个?-这似乎是我的问题的一部分。。。接下来的问题是:我可以使用什么nuget包来管理“应用程序洞察”?