[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-9770c1de-5bd4-427b-96df-d4cc95f594f0":3,"$fONNyW4-nP-QY0DH5xLzTSMNzmbE7C_fwcrdo2Jc9yGU":43},{"id":4,"title":5,"description":6,"categoryId":7,"moduleId":8,"tags":9,"prompt":10,"icon":11,"source":12,"sourceUrl":13,"authorId":14,"authorName":15,"isPublic":16,"stars":17,"runs":18,"createdAt":19,"updatedAt":19,"module":20,"category":27,"packages":34},"9770c1de-5bd4-427b-96df-d4cc95f594f0","azure-mgmt-applicationinsights-dotnet","Azure应用洞察SDK for .NET。应用性能监控和可观察性资源管理。","cat_coding_devops","mod_coding","sickn33,coding","---\nname: azure-mgmt-applicationinsights-dotnet\ndescription: Azure Application Insights SDK for .NET. Application performance monitoring and observability resource management.\nrisk: unknown\nsource: community\ndate_added: '2026-02-27'\n---\n\n# Azure.ResourceManager.ApplicationInsights (.NET)\n\nAzure Resource Manager SDK for managing Application Insights resources for application performance monitoring.\n\n## Installation\n\n```bash\ndotnet add package Azure.ResourceManager.ApplicationInsights\ndotnet add package Azure.Identity\n```\n\n**Current Version**: v1.0.0 (GA)  \n**API Version**: 2022-06-15\n\n## Environment Variables\n\n```bash\nAZURE_SUBSCRIPTION_ID=\u003Cyour-subscription-id>\nAZURE_RESOURCE_GROUP=\u003Cyour-resource-group>\nAZURE_APPINSIGHTS_NAME=\u003Cyour-appinsights-component>\n```\n\n## Authentication\n\n```csharp\nusing Azure.Identity;\nusing Azure.ResourceManager;\nusing Azure.ResourceManager.ApplicationInsights;\n\nArmClient client = new ArmClient(new DefaultAzureCredential());\n```\n\n## Resource Hierarchy\n\n```\nSubscription\n└── ResourceGroup\n    └── ApplicationInsightsComponent          # App Insights resource\n        ├── ApplicationInsightsComponentApiKey  # API keys for programmatic access\n        ├── ComponentLinkedStorageAccount      # Linked storage for data export\n        └── (via component ID)\n            ├── WebTest                        # Availability tests\n            ├── Workbook                       # Workbooks for analysis\n            ├── WorkbookTemplate               # Workbook templates\n            └── MyWorkbook                     # Private workbooks\n```\n\n## Core Workflows\n\n### 1. Create Application Insights Component (Workspace-based)\n\n```csharp\nusing Azure.ResourceManager.ApplicationInsights;\nusing Azure.ResourceManager.ApplicationInsights.Models;\n\nResourceGroupResource resourceGroup = await client\n    .GetDefaultSubscriptionAsync()\n    .Result\n    .GetResourceGroupAsync(\"my-resource-group\");\n\nApplicationInsightsComponentCollection components = resourceGroup.GetApplicationInsightsComponents();\n\n\u002F\u002F Workspace-based Application Insights (recommended)\nApplicationInsightsComponentData data = new ApplicationInsightsComponentData(\n    AzureLocation.EastUS,\n    ApplicationInsightsApplicationType.Web)\n{\n    Kind = \"web\",\n    WorkspaceResourceId = new ResourceIdentifier(\n        \"\u002Fsubscriptions\u002F\u003Csub-id>\u002FresourceGroups\u002F\u003Crg>\u002Fproviders\u002FMicrosoft.OperationalInsights\u002Fworkspaces\u002F\u003Cworkspace-name>\"),\n    IngestionMode = IngestionMode.LogAnalytics,\n    PublicNetworkAccessForIngestion = PublicNetworkAccessType.Enabled,\n    PublicNetworkAccessForQuery = PublicNetworkAccessType.Enabled,\n    RetentionInDays = 90,\n    SamplingPercentage = 100,\n    DisableIPMasking = false,\n    ImmediatePurgeDataOn30Days = false,\n    Tags =\n    {\n        { \"environment\", \"production\" },\n        { \"application\", \"mywebapp\" }\n    }\n};\n\nArmOperation\u003CApplicationInsightsComponentResource> operation = await components\n    .CreateOrUpdateAsync(WaitUntil.Completed, \"my-appinsights\", data);\n\nApplicationInsightsComponentResource component = operation.Value;\n\nConsole.WriteLine($\"Component created: {component.Data.Name}\");\nConsole.WriteLine($\"Instrumentation Key: {component.Data.InstrumentationKey}\");\nConsole.WriteLine($\"Connection String: {component.Data.ConnectionString}\");\n```\n\n### 2. Get Connection String and Keys\n\n```csharp\nApplicationInsightsComponentResource component = await resourceGroup\n    .GetApplicationInsightsComponentAsync(\"my-appinsights\");\n\n\u002F\u002F Get connection string for SDK configuration\nstring connectionString = component.Data.ConnectionString;\nstring instrumentationKey = component.Data.InstrumentationKey;\nstring appId = component.Data.AppId;\n\nConsole.WriteLine($\"Connection String: {connectionString}\");\nConsole.WriteLine($\"Instrumentation Key: {instrumentationKey}\");\nConsole.WriteLine($\"App ID: {appId}\");\n```\n\n### 3. Create API Key\n\n```csharp\nApplicationInsightsComponentResource component = await resourceGroup\n    .GetApplicationInsightsComponentAsync(\"my-appinsights\");\n\nApplicationInsightsComponentApiKeyCollection apiKeys = component.GetApplicationInsightsComponentApiKeys();\n\n\u002F\u002F API key for reading telemetry\nApplicationInsightsApiKeyContent keyContent = new ApplicationInsightsApiKeyContent\n{\n    Name = \"ReadTelemetryKey\",\n    LinkedReadProperties =\n    {\n        $\"\u002Fsubscriptions\u002F{subscriptionId}\u002FresourceGroups\u002F{resourceGroupName}\u002Fproviders\u002Fmicrosoft.insights\u002Fcomponents\u002F{component.Data.Name}\u002Fapi\",\n        $\"\u002Fsubscriptions\u002F{subscriptionId}\u002FresourceGroups\u002F{resourceGroupName}\u002Fproviders\u002Fmicrosoft.insights\u002Fcomponents\u002F{component.Data.Name}\u002Fagentconfig\"\n    }\n};\n\nApplicationInsightsComponentApiKeyResource apiKey = await apiKeys\n    .CreateOrUpdateAsync(WaitUntil.Completed, keyContent);\n\nConsole.WriteLine($\"API Key Name: {apiKey.Data.Name}\");\nConsole.WriteLine($\"API Key: {apiKey.Data.ApiKey}\"); \u002F\u002F Only shown once!\n```\n\n### 4. Create Web Test (Availability Test)\n\n```csharp\nWebTestCollection webTests = resourceGroup.GetWebTests();\n\n\u002F\u002F URL Ping Test\nWebTestData urlPingTest = new WebTestData(AzureLocation.EastUS)\n{\n    Kind = WebTestKind.Ping,\n    SyntheticMonitorId = \"webtest-ping-myapp\",\n    WebTestName = \"Homepage Availability\",\n    Description = \"Checks if homepage is available\",\n    IsEnabled = true,\n    Frequency = 300, \u002F\u002F 5 minutes\n    Timeout = 120,   \u002F\u002F 2 minutes\n    WebTestKind = WebTestKind.Ping,\n    IsRetryEnabled = true,\n    Locations =\n    {\n        new WebTestGeolocation { WebTestLocationId = \"us-ca-sjc-azr\" },  \u002F\u002F West US\n        new WebTestGeolocation { WebTestLocationId = \"us-tx-sn1-azr\" },  \u002F\u002F South Central US\n        new WebTestGeolocation { WebTestLocationId = \"us-il-ch1-azr\" },  \u002F\u002F North Central US\n        new WebTestGeolocation { WebTestLocationId = \"emea-gb-db3-azr\" }, \u002F\u002F UK South\n        new WebTestGeolocation { WebTestLocationId = \"apac-sg-sin-azr\" }  \u002F\u002F Southeast Asia\n    },\n    Configuration = new WebTestConfiguration\n    {\n        WebTest = \"\"\"\n            \u003CWebTest Name=\"Homepage\" Enabled=\"True\" Timeout=\"120\" \n                     xmlns=\"http:\u002F\u002Fmicrosoft.com\u002Fschemas\u002FVisualStudio\u002FTeamTest\u002F2010\">\n                \u003CItems>\n                    \u003CRequest Method=\"GET\" Version=\"1.1\" Url=\"https:\u002F\u002Fmyapp.example.com\" \n                             ThinkTime=\"0\" Timeout=\"120\" ParseDependentRequests=\"False\" \n                             FollowRedirects=\"True\" RecordResult=\"True\" Cache=\"False\" \n                             ResponseTimeGoal=\"0\" Encoding=\"utf-8\" ExpectedHttpStatusCode=\"200\" \u002F>\n                \u003C\u002FItems>\n            \u003C\u002FWebTest>\n        \"\"\"\n    },\n    Tags =\n    {\n        { $\"hidden-link:\u002Fsubscriptions\u002F{subscriptionId}\u002FresourceGroups\u002F{resourceGroupName}\u002Fproviders\u002Fmicrosoft.insights\u002Fcomponents\u002Fmy-appinsights\", \"Resource\" }\n    }\n};\n\nArmOperation\u003CWebTestResource> operation = await webTests\n    .CreateOrUpdateAsync(WaitUntil.Completed, \"webtest-homepage\", urlPingTest);\n\nWebTestResource webTest = operation.Value;\nConsole.WriteLine($\"Web test created: {webTest.Data.Name}\");\n```\n\n### 5. Create Multi-Step Web Test\n\n```csharp\nWebTestData multiStepTest = new WebTestData(AzureLocation.EastUS)\n{\n    Kind = WebTestKind.MultiStep,\n    SyntheticMonitorId = \"webtest-multistep-login\",\n    WebTestName = \"Login Flow Test\",\n    Description = \"Tests login functionality\",\n    IsEnabled = true,\n    Frequency = 900, \u002F\u002F 15 minutes\n    Timeout = 300,   \u002F\u002F 5 minutes\n    WebTestKind = WebTestKind.MultiStep,\n    IsRetryEnabled = true,\n    Locations =\n    {\n        new WebTestGeolocation { WebTestLocationId = \"us-ca-sjc-azr\" }\n    },\n    Configuration = new WebTestConfiguration\n    {\n        WebTest = \"\"\"\n            \u003CWebTest Name=\"LoginFlow\" Enabled=\"True\" Timeout=\"300\"\n                     xmlns=\"http:\u002F\u002Fmicrosoft.com\u002Fschemas\u002FVisualStudio\u002FTeamTest\u002F2010\">\n                \u003CItems>\n                    \u003CRequest Method=\"GET\" Version=\"1.1\" Url=\"https:\u002F\u002Fmyapp.example.com\u002Flogin\" \n                             ThinkTime=\"0\" Timeout=\"60\" \u002F>\n                    \u003CRequest Method=\"POST\" Version=\"1.1\" Url=\"https:\u002F\u002Fmyapp.example.com\u002Fapi\u002Fauth\" \n                             ThinkTime=\"0\" Timeout=\"60\">\n                        \u003CHeaders>\n                            \u003CHeader Name=\"Content-Type\" Value=\"application\u002Fjson\" \u002F>\n                        \u003C\u002FHeaders>\n                        \u003CBody>{\"username\":\"testuser\",\"password\":\"{{TestPassword}}\"}\u003C\u002FBody>\n                    \u003C\u002FRequest>\n                \u003C\u002FItems>\n            \u003C\u002FWebTest>\n        \"\"\"\n    },\n    Tags =\n    {\n        { $\"hidden-link:\u002Fsubscriptions\u002F{subscriptionId}\u002FresourceGroups\u002F{resourceGroupName}\u002Fproviders\u002Fmicrosoft.insights\u002Fcomponents\u002Fmy-appinsights\", \"Resource\" }\n    }\n};\n\nawait webTests.CreateOrUpdateAsync(WaitUntil.Completed, \"webtest-login-flow\", multiStepTest);\n```\n\n### 6. Create Workbook\n\n```csharp\nWorkbookCollection workbooks = resourceGroup.GetWorkbooks();\n\nWorkbookData workbookData = new WorkbookData(AzureLocation.EastUS)\n{\n    DisplayName = \"Application Performance Dashboard\",\n    Category = \"workbook\",\n    Kind = WorkbookSharedTypeKind.Shared,\n    SerializedData = \"\"\"\n    {\n        \"version\": \"Notebook\u002F1.0\",\n        \"items\": [\n            {\n                \"type\": 1,\n                \"content\": {\n                    \"json\": \"# Application Performance\\n\\nThis workbook shows application performance metrics.\"\n                },\n                \"name\": \"header\"\n            },\n            {\n                \"type\": 3,\n                \"content\": {\n                    \"version\": \"KqlItem\u002F1.0\",\n                    \"query\": \"requests\\n| summarize count() by bin(timestamp, 1h)\\n| render timechart\",\n                    \"size\": 0,\n                    \"title\": \"Requests per Hour\",\n                    \"timeContext\": {\n                        \"durationMs\": 86400000\n                    },\n                    \"queryType\": 0,\n                    \"resourceType\": \"microsoft.insights\u002Fcomponents\"\n                },\n                \"name\": \"requestsChart\"\n            }\n        ],\n        \"isLocked\": false\n    }\n    \"\"\",\n    SourceId = component.Id,\n    Tags =\n    {\n        { \"environment\", \"production\" }\n    }\n};\n\n\u002F\u002F Note: Workbook ID should be a new GUID\nstring workbookId = Guid.NewGuid().ToString();\n\nArmOperation\u003CWorkbookResource> operation = await workbooks\n    .CreateOrUpdateAsync(WaitUntil.Completed, workbookId, workbookData);\n\nWorkbookResource workbook = operation.Value;\nConsole.WriteLine($\"Workbook created: {workbook.Data.DisplayName}\");\n```\n\n### 7. Link Storage Account\n\n```csharp\nApplicationInsightsComponentResource component = await resourceGroup\n    .GetApplicationInsightsComponentAsync(\"my-appinsights\");\n\nComponentLinkedStorageAccountCollection linkedStorage = component.GetComponentLinkedStorageAccounts();\n\nComponentLinkedStorageAccountData storageData = new ComponentLinkedStorageAccountData\n{\n    LinkedStorageAccount = new ResourceIdentifier(\n        \"\u002Fsubscriptions\u002F\u003Csub-id>\u002FresourceGroups\u002F\u003Crg>\u002Fproviders\u002FMicrosoft.Storage\u002FstorageAccounts\u002F\u003Cstorage-account>\")\n};\n\nArmOperation\u003CComponentLinkedStorageAccountResource> operation = await linkedStorage\n    .CreateOrUpdateAsync(WaitUntil.Completed, StorageType.ServiceProfiler, storageData);\n```\n\n### 8. List and Manage Components\n\n```csharp\n\u002F\u002F List all Application Insights components in resource group\nawait foreach (ApplicationInsightsComponentResource component in \n    resourceGroup.GetApplicationInsightsComponents())\n{\n    Console.WriteLine($\"Component: {component.Data.Name}\");\n    Console.WriteLine($\"  App ID: {component.Data.AppId}\");\n    Console.WriteLine($\"  Type: {component.Data.ApplicationType}\");\n    Console.WriteLine($\"  Ingestion Mode: {component.Data.IngestionMode}\");\n    Console.WriteLine($\"  Retention: {component.Data.RetentionInDays} days\");\n}\n\n\u002F\u002F List web tests\nawait foreach (WebTestResource webTest in resourceGroup.GetWebTests())\n{\n    Console.WriteLine($\"Web Test: {webTest.Data.WebTestName}\");\n    Console.WriteLine($\"  Enabled: {webTest.Data.IsEnabled}\");\n    Console.WriteLine($\"  Frequency: {webTest.Data.Frequency}s\");\n}\n\n\u002F\u002F List workbooks\nawait foreach (WorkbookResource workbook in resourceGroup.GetWorkbooks())\n{\n    Console.WriteLine($\"Workbook: {workbook.Data.DisplayName}\");\n}\n```\n\n### 9. Update Component\n\n```csharp\nApplicationInsightsComponentResource component = await resourceGroup\n    .GetApplicationInsightsComponentAsync(\"my-appinsights\");\n\n\u002F\u002F Update using full data (PUT operation)\nApplicationInsightsComponentData updateData = component.Data;\nupdateData.RetentionInDays = 180;\nupdateData.SamplingPercentage = 50;\nupdateData.Tags[\"updated\"] = \"true\";\n\nArmOperation\u003CApplicationInsightsComponentResource> operation = await resourceGroup\n    .GetApplicationInsightsComponents()\n    .CreateOrUpdateAsync(WaitUntil.Completed, \"my-appinsights\", updateData);\n```\n\n### 10. Delete Resources\n\n```csharp\n\u002F\u002F Delete Application Insights component\nApplicationInsightsComponentResource component = await resourceGroup\n    .GetApplicationInsightsComponentAsync(\"my-appinsights\");\nawait component.DeleteAsync(WaitUntil.Completed);\n\n\u002F\u002F Delete web test\nWebTestResource webTest = await resourceGroup.GetWebTestAsync(\"webtest-homepage\");\nawait webTest.DeleteAsync(WaitUntil.Completed);\n```\n\n## Key Types Reference\n\n| Type | Purpose |\n|------|---------|\n| `ApplicationInsightsComponentResource` | App Insights component |\n| `ApplicationInsightsComponentData` | Component configuration |\n| `ApplicationInsightsComponentCollection` | Collection of components |\n| `ApplicationInsightsComponentApiKeyResource` | API key for programmatic access |\n| `WebTestResource` | Availability\u002Fweb test |\n| `WebTestData` | Web test configuration |\n| `WorkbookResource` | Analysis workbook |\n| `WorkbookData` | Workbook configuration |\n| `ComponentLinkedStorageAccountResource` | Linked storage for exports |\n\n## Application Types\n\n| Type | Enum Value |\n|------|------------|\n| Web Application | `Web` |\n| iOS Application | `iOS` |\n| Java Application | `Java` |\n| Node.js Application | `NodeJS` |\n| .NET Application | `MRT` |\n| Other | `Other` |\n\n## Web Test Locations\n\n| Location ID | Region |\n|-------------|--------|\n| `us-ca-sjc-azr` | West US |\n| `us-tx-sn1-azr` | South Central US |\n| `us-il-ch1-azr` | North Central US |\n| `us-va-ash-azr` | East US |\n| `emea-gb-db3-azr` | UK South |\n| `emea-nl-ams-azr` | West Europe |\n| `emea-fr-pra-edge` | France Central |\n| `apac-sg-sin-azr` | Southeast Asia |\n| `apac-hk-hkn-azr` | East Asia |\n| `apac-jp-kaw-edge` | Japan East |\n| `latam-br-gru-edge` | Brazil South |\n| `emea-au-syd-edge` | Australia East |\n\n## Best Practices\n\n1. **Use workspace-based** — Workspace-based App Insights is the current standard\n2. **Link to Log Analytics** — Store data in Log Analytics for better querying\n3. **Set appropriate retention** — Balance cost vs. data availability\n4. **Use sampling** — Reduce costs for high-volume applications\n5. **Store connection string securely** — Use Key Vault or managed identity\n6. **Enable multiple test locations** — For accurate availability monitoring\n7. **Use workbooks** — For custom dashboards and analysis\n8. **Set up alerts** — Based on availability tests and metrics\n9. **Tag resources** — For cost allocation and organization\n10. **Use private endpoints** — For secure data ingestion\n\n## Error Handling\n\n```csharp\nusing Azure;\n\ntry\n{\n    ArmOperation\u003CApplicationInsightsComponentResource> operation = await components\n        .CreateOrUpdateAsync(WaitUntil.Completed, \"my-appinsights\", data);\n}\ncatch (RequestFailedException ex) when (ex.Status == 409)\n{\n    Console.WriteLine(\"Component already exists\");\n}\ncatch (RequestFailedException ex) when (ex.Status == 400)\n{\n    Console.WriteLine($\"Invalid configuration: {ex.Message}\");\n}\ncatch (RequestFailedException ex)\n{\n    Console.WriteLine($\"Azure error: {ex.Status} - {ex.Message}\");\n}\n```\n\n## SDK Integration\n\nUse the connection string with Application Insights SDK:\n\n```csharp\n\u002F\u002F Program.cs in ASP.NET Core\nbuilder.Services.AddApplicationInsightsTelemetry(options =>\n{\n    options.ConnectionString = configuration[\"ApplicationInsights:ConnectionString\"];\n});\n\n\u002F\u002F Or set via environment variable\n\u002F\u002F APPLICATIONINSIGHTS_CONNECTION_STRING=InstrumentationKey=...;IngestionEndpoint=...\n```\n\n## Related SDKs\n\n| SDK | Purpose | Install |\n|-----|---------|---------|\n| `Azure.ResourceManager.ApplicationInsights` | Resource management (this SDK) | `dotnet add package Azure.ResourceManager.ApplicationInsights` |\n| `Microsoft.ApplicationInsights` | Telemetry SDK | `dotnet add package Microsoft.ApplicationInsights` |\n| `Microsoft.ApplicationInsights.AspNetCore` | ASP.NET Core integration | `dotnet add package Microsoft.ApplicationInsights.AspNetCore` |\n| `Azure.Monitor.OpenTelemetry.Exporter` | OpenTelemetry export | `dotnet add package Azure.Monitor.OpenTelemetry.Exporter` |\n\n## Reference Links\n\n| Resource | URL |\n|----------|-----|\n| NuGet Package | https:\u002F\u002Fwww.nuget.org\u002Fpackages\u002FAzure.ResourceManager.ApplicationInsights |\n| API Reference | https:\u002F\u002Flearn.microsoft.com\u002Fdotnet\u002Fapi\u002Fazure.resourcemanager.applicationinsights |\n| Product Documentation | https:\u002F\u002Flearn.microsoft.com\u002Fazure\u002Fazure-monitor\u002Fapp\u002Fapp-insights-overview |\n| GitHub Source | https:\u002F\u002Fgithub.com\u002FAzure\u002Fazure-sdk-for-net\u002Ftree\u002Fmain\u002Fsdk\u002Fapplicationinsights\u002FAzure.ResourceManager.ApplicationInsights |\n\n## When to Use\nThis skill is applicable to execute the workflow or actions described in the overview.\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.\n","","imported","https:\u002F\u002Fgithub.com\u002Fsickn33\u002Fantigravity-awesome-skills","user_system_seed","SkillOPIC",true,109,1810,"2026-05-16 13:06:56",{"id":8,"name":21,"slug":22,"icon":23,"description":24,"sort":25,"createdAt":26},"编程开发","coding","mdi-code-braces","代码生成、调试、审查，提升开发效率",2,"2026-05-16 12:53:40",{"id":7,"name":28,"slug":29,"icon":30,"description":31,"moduleId":8,"sort":32,"skillCount":33,"createdAt":26},"DevOps","devops","mdi-cog-outline","CI\u002FCD、容器化、部署运维",3,162,[35],{"id":36,"skillId":4,"version":37,"fileName":38,"fileSize":39,"filePath":40,"fileHash":41,"manifest":42,"createdAt":19},"64b562f0-fe32-4b7e-af62-ad42f2c2cac6","1.0.0","azure-mgmt-applicationinsights-dotnet.zip",4972,"uploads\u002Fskills\u002F9770c1de-5bd4-427b-96df-d4cc95f594f0\u002Fazure-mgmt-applicationinsights-dotnet.zip","f26fcf460266f0f1f877c3443c1db8c0e888c62f320d22cb29e3436e7031c686","[{\"path\":\"SKILL.md\",\"isDirectory\":false,\"size\":17721}]",{"code":44,"message":45,"data":46},200,"success",{"items":47,"stats":48,"page":51},[],{"averageRating":49,"totalRatings":49,"ratingCounts":50},0,[49,49,49,49,49],{"limit":52,"offset":49,"hasMore":53,"nextOffset":52,"ratedOnly":16},15,false]