|
Add this skill
npx mdskills install sickn33/azure-mgmt-applicationinsights-dotnetComprehensive Azure SDK reference with rich examples but lacks agent-specific triggers and decision logic
Azure Resource Manager SDK for managing Application Insights resources for application performance monitoring.
dotnet add package Azure.ResourceManager.ApplicationInsights
dotnet add package Azure.Identity
Current Version: v1.0.0 (GA)
API Version: 2022-06-15
AZURE_SUBSCRIPTION_ID=
AZURE_RESOURCE_GROUP=
AZURE_APPINSIGHTS_NAME=
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.ApplicationInsights;
ArmClient client = new ArmClient(new DefaultAzureCredential());
Subscription
└── ResourceGroup
└── ApplicationInsightsComponent # App Insights resource
├── ApplicationInsightsComponentApiKey # API keys for programmatic access
├── ComponentLinkedStorageAccount # Linked storage for data export
└── (via component ID)
├── WebTest # Availability tests
├── Workbook # Workbooks for analysis
├── WorkbookTemplate # Workbook templates
└── MyWorkbook # Private workbooks
using Azure.ResourceManager.ApplicationInsights;
using Azure.ResourceManager.ApplicationInsights.Models;
ResourceGroupResource resourceGroup = await client
.GetDefaultSubscriptionAsync()
.Result
.GetResourceGroupAsync("my-resource-group");
ApplicationInsightsComponentCollection components = resourceGroup.GetApplicationInsightsComponents();
// Workspace-based Application Insights (recommended)
ApplicationInsightsComponentData data = new ApplicationInsightsComponentData(
AzureLocation.EastUS,
ApplicationInsightsApplicationType.Web)
{
Kind = "web",
WorkspaceResourceId = new ResourceIdentifier(
"/subscriptions//resourceGroups//providers/Microsoft.OperationalInsights/workspaces/"),
IngestionMode = IngestionMode.LogAnalytics,
PublicNetworkAccessForIngestion = PublicNetworkAccessType.Enabled,
PublicNetworkAccessForQuery = PublicNetworkAccessType.Enabled,
RetentionInDays = 90,
SamplingPercentage = 100,
DisableIPMasking = false,
ImmediatePurgeDataOn30Days = false,
Tags =
{
{ "environment", "production" },
{ "application", "mywebapp" }
}
};
ArmOperation operation = await components
.CreateOrUpdateAsync(WaitUntil.Completed, "my-appinsights", data);
ApplicationInsightsComponentResource component = operation.Value;
Console.WriteLine($"Component created: {component.Data.Name}");
Console.WriteLine($"Instrumentation Key: {component.Data.InstrumentationKey}");
Console.WriteLine($"Connection String: {component.Data.ConnectionString}");
ApplicationInsightsComponentResource component = await resourceGroup
.GetApplicationInsightsComponentAsync("my-appinsights");
// Get connection string for SDK configuration
string connectionString = component.Data.ConnectionString;
string instrumentationKey = component.Data.InstrumentationKey;
string appId = component.Data.AppId;
Console.WriteLine($"Connection String: {connectionString}");
Console.WriteLine($"Instrumentation Key: {instrumentationKey}");
Console.WriteLine($"App ID: {appId}");
ApplicationInsightsComponentResource component = await resourceGroup
.GetApplicationInsightsComponentAsync("my-appinsights");
ApplicationInsightsComponentApiKeyCollection apiKeys = component.GetApplicationInsightsComponentApiKeys();
// API key for reading telemetry
ApplicationInsightsApiKeyContent keyContent = new ApplicationInsightsApiKeyContent
{
Name = "ReadTelemetryKey",
LinkedReadProperties =
{
$"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{component.Data.Name}/api",
$"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/{component.Data.Name}/agentconfig"
}
};
ApplicationInsightsComponentApiKeyResource apiKey = await apiKeys
.CreateOrUpdateAsync(WaitUntil.Completed, keyContent);
Console.WriteLine($"API Key Name: {apiKey.Data.Name}");
Console.WriteLine($"API Key: {apiKey.Data.ApiKey}"); // Only shown once!
WebTestCollection webTests = resourceGroup.GetWebTests();
// URL Ping Test
WebTestData urlPingTest = new WebTestData(AzureLocation.EastUS)
{
Kind = WebTestKind.Ping,
SyntheticMonitorId = "webtest-ping-myapp",
WebTestName = "Homepage Availability",
Description = "Checks if homepage is available",
IsEnabled = true,
Frequency = 300, // 5 minutes
Timeout = 120, // 2 minutes
WebTestKind = WebTestKind.Ping,
IsRetryEnabled = true,
Locations =
{
new WebTestGeolocation { WebTestLocationId = "us-ca-sjc-azr" }, // West US
new WebTestGeolocation { WebTestLocationId = "us-tx-sn1-azr" }, // South Central US
new WebTestGeolocation { WebTestLocationId = "us-il-ch1-azr" }, // North Central US
new WebTestGeolocation { WebTestLocationId = "emea-gb-db3-azr" }, // UK South
new WebTestGeolocation { WebTestLocationId = "apac-sg-sin-azr" } // Southeast Asia
},
Configuration = new WebTestConfiguration
{
WebTest = """
"""
},
Tags =
{
{ $"hidden-link:/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/my-appinsights", "Resource" }
}
};
ArmOperation operation = await webTests
.CreateOrUpdateAsync(WaitUntil.Completed, "webtest-homepage", urlPingTest);
WebTestResource webTest = operation.Value;
Console.WriteLine($"Web test created: {webTest.Data.Name}");
WebTestData multiStepTest = new WebTestData(AzureLocation.EastUS)
{
Kind = WebTestKind.MultiStep,
SyntheticMonitorId = "webtest-multistep-login",
WebTestName = "Login Flow Test",
Description = "Tests login functionality",
IsEnabled = true,
Frequency = 900, // 15 minutes
Timeout = 300, // 5 minutes
WebTestKind = WebTestKind.MultiStep,
IsRetryEnabled = true,
Locations =
{
new WebTestGeolocation { WebTestLocationId = "us-ca-sjc-azr" }
},
Configuration = new WebTestConfiguration
{
WebTest = """
{"username":"testuser","password":"{{TestPassword}}"}
"""
},
Tags =
{
{ $"hidden-link:/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/components/my-appinsights", "Resource" }
}
};
await webTests.CreateOrUpdateAsync(WaitUntil.Completed, "webtest-login-flow", multiStepTest);
WorkbookCollection workbooks = resourceGroup.GetWorkbooks();
WorkbookData workbookData = new WorkbookData(AzureLocation.EastUS)
{
DisplayName = "Application Performance Dashboard",
Category = "workbook",
Kind = WorkbookSharedTypeKind.Shared,
SerializedData = """
{
"version": "Notebook/1.0",
"items": [
{
"type": 1,
"content": {
"json": "# Application Performance\n\nThis workbook shows application performance metrics."
},
"name": "header"
},
{
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "requests\n| summarize count() by bin(timestamp, 1h)\n| render timechart",
"size": 0,
"title": "Requests per Hour",
"timeContext": {
"durationMs": 86400000
},
"queryType": 0,
"resourceType": "microsoft.insights/components"
},
"name": "requestsChart"
}
],
"isLocked": false
}
""",
SourceId = component.Id,
Tags =
{
{ "environment", "production" }
}
};
// Note: Workbook ID should be a new GUID
string workbookId = Guid.NewGuid().ToString();
ArmOperation operation = await workbooks
.CreateOrUpdateAsync(WaitUntil.Completed, workbookId, workbookData);
WorkbookResource workbook = operation.Value;
Console.WriteLine($"Workbook created: {workbook.Data.DisplayName}");
ApplicationInsightsComponentResource component = await resourceGroup
.GetApplicationInsightsComponentAsync("my-appinsights");
ComponentLinkedStorageAccountCollection linkedStorage = component.GetComponentLinkedStorageAccounts();
ComponentLinkedStorageAccountData storageData = new ComponentLinkedStorageAccountData
{
LinkedStorageAccount = new ResourceIdentifier(
"/subscriptions//resourceGroups//providers/Microsoft.Storage/storageAccounts/")
};
ArmOperation operation = await linkedStorage
.CreateOrUpdateAsync(WaitUntil.Completed, StorageType.ServiceProfiler, storageData);
// List all Application Insights components in resource group
await foreach (ApplicationInsightsComponentResource component in
resourceGroup.GetApplicationInsightsComponents())
{
Console.WriteLine($"Component: {component.Data.Name}");
Console.WriteLine($" App ID: {component.Data.AppId}");
Console.WriteLine($" Type: {component.Data.ApplicationType}");
Console.WriteLine($" Ingestion Mode: {component.Data.IngestionMode}");
Console.WriteLine($" Retention: {component.Data.RetentionInDays} days");
}
// List web tests
await foreach (WebTestResource webTest in resourceGroup.GetWebTests())
{
Console.WriteLine($"Web Test: {webTest.Data.WebTestName}");
Console.WriteLine($" Enabled: {webTest.Data.IsEnabled}");
Console.WriteLine($" Frequency: {webTest.Data.Frequency}s");
}
// List workbooks
await foreach (WorkbookResource workbook in resourceGroup.GetWorkbooks())
{
Console.WriteLine($"Workbook: {workbook.Data.DisplayName}");
}
ApplicationInsightsComponentResource component = await resourceGroup
.GetApplicationInsightsComponentAsync("my-appinsights");
// Update using full data (PUT operation)
ApplicationInsightsComponentData updateData = component.Data;
updateData.RetentionInDays = 180;
updateData.SamplingPercentage = 50;
updateData.Tags["updated"] = "true";
ArmOperation operation = await resourceGroup
.GetApplicationInsightsComponents()
.CreateOrUpdateAsync(WaitUntil.Completed, "my-appinsights", updateData);
// Delete Application Insights component
ApplicationInsightsComponentResource component = await resourceGroup
.GetApplicationInsightsComponentAsync("my-appinsights");
await component.DeleteAsync(WaitUntil.Completed);
// Delete web test
WebTestResource webTest = await resourceGroup.GetWebTestAsync("webtest-homepage");
await webTest.DeleteAsync(WaitUntil.Completed);
| Type | Purpose |
|---|---|
ApplicationInsightsComponentResource | App Insights component |
ApplicationInsightsComponentData | Component configuration |
ApplicationInsightsComponentCollection | Collection of components |
ApplicationInsightsComponentApiKeyResource | API key for programmatic access |
WebTestResource | Availability/web test |
WebTestData | Web test configuration |
WorkbookResource | Analysis workbook |
WorkbookData | Workbook configuration |
ComponentLinkedStorageAccountResource | Linked storage for exports |
| Type | Enum Value |
|---|---|
| Web Application | Web |
| iOS Application | iOS |
| Java Application | Java |
| Node.js Application | NodeJS |
| .NET Application | MRT |
| Other | Other |
| Location ID | Region |
|---|---|
us-ca-sjc-azr | West US |
us-tx-sn1-azr | South Central US |
us-il-ch1-azr | North Central US |
us-va-ash-azr | East US |
emea-gb-db3-azr | UK South |
emea-nl-ams-azr | West Europe |
emea-fr-pra-edge | France Central |
apac-sg-sin-azr | Southeast Asia |
apac-hk-hkn-azr | East Asia |
apac-jp-kaw-edge | Japan East |
latam-br-gru-edge | Brazil South |
emea-au-syd-edge | Australia East |
using Azure;
try
{
ArmOperation operation = await components
.CreateOrUpdateAsync(WaitUntil.Completed, "my-appinsights", data);
}
catch (RequestFailedException ex) when (ex.Status == 409)
{
Console.WriteLine("Component already exists");
}
catch (RequestFailedException ex) when (ex.Status == 400)
{
Console.WriteLine($"Invalid configuration: {ex.Message}");
}
catch (RequestFailedException ex)
{
Console.WriteLine($"Azure error: {ex.Status} - {ex.Message}");
}
Use the connection string with Application Insights SDK:
// Program.cs in ASP.NET Core
builder.Services.AddApplicationInsightsTelemetry(options =>
{
options.ConnectionString = configuration["ApplicationInsights:ConnectionString"];
});
// Or set via environment variable
// APPLICATIONINSIGHTS_CONNECTION_STRING=InstrumentationKey=...;IngestionEndpoint=...
| SDK | Purpose | Install |
|---|---|---|
Azure.ResourceManager.ApplicationInsights | Resource management (this SDK) | dotnet add package Azure.ResourceManager.ApplicationInsights |
Microsoft.ApplicationInsights | Telemetry SDK | dotnet add package Microsoft.ApplicationInsights |
Microsoft.ApplicationInsights.AspNetCore | ASP.NET Core integration | dotnet add package Microsoft.ApplicationInsights.AspNetCore |
Azure.Monitor.OpenTelemetry.Exporter | OpenTelemetry export | dotnet add package Azure.Monitor.OpenTelemetry.Exporter |
Install via CLI
npx mdskills install sickn33/azure-mgmt-applicationinsights-dotnetAzure Mgmt Applicationinsights Dotnet is a free, open-source AI agent skill. |
Install Azure Mgmt Applicationinsights Dotnet with a single command:
npx mdskills install sickn33/azure-mgmt-applicationinsights-dotnetThis downloads the skill files into your project and your AI agent picks them up automatically.
Azure Mgmt Applicationinsights Dotnet works with Claude Code, Claude Desktop, Cursor, Vscode Copilot, Windsurf, Continue Dev, Codex, Gemini Cli, Amp, Roo Code, Goose, Opencode, Trae, Qodo, Command Code. Skills use the open SKILL.md format which is compatible with any AI coding agent that reads markdown instructions.