diff --git a/eng/Packages.Data.props b/eng/Packages.Data.props
index 3e9cdbd35a061..3a1d58e3b58cc 100644
--- a/eng/Packages.Data.props
+++ b/eng/Packages.Data.props
@@ -131,6 +131,7 @@
+
diff --git a/sdk/provisioning/Azure.Provisioning/api/Azure.Provisioning.net6.0.cs b/sdk/provisioning/Azure.Provisioning/api/Azure.Provisioning.net6.0.cs
index 31aa668b3e6c6..5263aa579171b 100644
--- a/sdk/provisioning/Azure.Provisioning/api/Azure.Provisioning.net6.0.cs
+++ b/sdk/provisioning/Azure.Provisioning/api/Azure.Provisioning.net6.0.cs
@@ -129,6 +129,15 @@ public partial class AppConfigurationStore : Azure.Provisioning.Resource
+ {
+ public ApplicationInsightsComponent(Azure.Provisioning.IConstruct scope, string kind = "web", string applicationType = "web", Azure.Provisioning.ResourceManager.ResourceGroup? parent = null, string name = "appinsights", string version = "2020-02-02", Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?)) : base (default(Azure.Provisioning.IConstruct), default(Azure.Provisioning.Resource), default(string), default(Azure.Core.ResourceType), default(string), default(System.Func)) { }
+ public static Azure.Provisioning.ApplicationInsights.ApplicationInsightsComponent FromExisting(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.ResourceManager.ResourceGroup? parent = null) { throw null; }
+ protected override string GetAzureName(Azure.Provisioning.IConstruct scope, string resourceName) { throw null; }
+ }
+}
namespace Azure.Provisioning.AppService
{
public partial class AppServicePlan : Azure.Provisioning.Resource
diff --git a/sdk/provisioning/Azure.Provisioning/api/Azure.Provisioning.netstandard2.0.cs b/sdk/provisioning/Azure.Provisioning/api/Azure.Provisioning.netstandard2.0.cs
index 31aa668b3e6c6..5263aa579171b 100644
--- a/sdk/provisioning/Azure.Provisioning/api/Azure.Provisioning.netstandard2.0.cs
+++ b/sdk/provisioning/Azure.Provisioning/api/Azure.Provisioning.netstandard2.0.cs
@@ -129,6 +129,15 @@ public partial class AppConfigurationStore : Azure.Provisioning.Resource
+ {
+ public ApplicationInsightsComponent(Azure.Provisioning.IConstruct scope, string kind = "web", string applicationType = "web", Azure.Provisioning.ResourceManager.ResourceGroup? parent = null, string name = "appinsights", string version = "2020-02-02", Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?)) : base (default(Azure.Provisioning.IConstruct), default(Azure.Provisioning.Resource), default(string), default(Azure.Core.ResourceType), default(string), default(System.Func)) { }
+ public static Azure.Provisioning.ApplicationInsights.ApplicationInsightsComponent FromExisting(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.ResourceManager.ResourceGroup? parent = null) { throw null; }
+ protected override string GetAzureName(Azure.Provisioning.IConstruct scope, string resourceName) { throw null; }
+ }
+}
namespace Azure.Provisioning.AppService
{
public partial class AppServicePlan : Azure.Provisioning.Resource
diff --git a/sdk/provisioning/Azure.Provisioning/assets.json b/sdk/provisioning/Azure.Provisioning/assets.json
index e9062854c9190..b5e67a21e6efc 100644
--- a/sdk/provisioning/Azure.Provisioning/assets.json
+++ b/sdk/provisioning/Azure.Provisioning/assets.json
@@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "net",
"TagPrefix": "net/provisioning/Azure.Provisioning",
- "Tag": "net/provisioning/Azure.Provisioning_1a8a692724"
+ "Tag": "net/provisioning/Azure.Provisioning_336cf2dff6"
}
\ No newline at end of file
diff --git a/sdk/provisioning/Azure.Provisioning/src/Azure.Provisioning.csproj b/sdk/provisioning/Azure.Provisioning/src/Azure.Provisioning.csproj
index 3b3d75a747fff..f8adfbe4e3012 100644
--- a/sdk/provisioning/Azure.Provisioning/src/Azure.Provisioning.csproj
+++ b/sdk/provisioning/Azure.Provisioning/src/Azure.Provisioning.csproj
@@ -25,6 +25,7 @@
+
diff --git a/sdk/provisioning/Azure.Provisioning/src/applicationinsights/ApplicationInsightsComponent.cs b/sdk/provisioning/Azure.Provisioning/src/applicationinsights/ApplicationInsightsComponent.cs
new file mode 100644
index 0000000000000..23457ad0de5f0
--- /dev/null
+++ b/sdk/provisioning/Azure.Provisioning/src/applicationinsights/ApplicationInsightsComponent.cs
@@ -0,0 +1,77 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+using System;
+using Azure.Core;
+using Azure.Provisioning.CosmosDB;
+using Azure.Provisioning.ResourceManager;
+using Azure.ResourceManager.ApplicationInsights;
+using Azure.ResourceManager.ApplicationInsights.Models;
+
+namespace Azure.Provisioning.ApplicationInsights
+{
+ ///
+ /// Represents an Application Insights component.
+ ///
+ public class ApplicationInsightsComponent : Resource
+ {
+ // https://learn.microsoft.com/azure/templates/microsoft.insights/2020-02-02/components?pivots=deployment-language-bicep
+ private const string ResourceTypeName = "Microsoft.Insights/components";
+ // https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/applicationinsights/Azure.ResourceManager.ApplicationInsights/src/Generated/RestOperations/ComponentsRestOperations.cs#L36
+ internal const string DefaultVersion = "2020-02-02";
+
+ private static readonly Func Empty = (name) => ArmApplicationInsightsModelFactory.ApplicationInsightsComponentData();
+
+ ///
+ /// Creates a new instance of the class.
+ ///
+ /// The scope.
+ /// The kind.
+ /// The application type.
+ /// The parent.
+ /// The name.
+ /// The version.
+ /// The location
+ public ApplicationInsightsComponent(
+ IConstruct scope,
+ string kind = "web",
+ string applicationType = "web",
+ ResourceGroup? parent = default,
+ string name = "appinsights",
+ string version = DefaultVersion,
+ AzureLocation? location = default)
+ : this(scope, parent, name, version, location, false, (name) => ArmApplicationInsightsModelFactory.ApplicationInsightsComponentData(
+ name: name,
+ location: location ?? Environment.GetEnvironmentVariable("AZURE_LOCATION") ?? AzureLocation.WestUS,
+ kind: kind,
+ applicationType: applicationType))
+ {
+ AssignProperty(data => data.Name, GetAzureName(scope, name));
+ }
+
+ private ApplicationInsightsComponent(
+ IConstruct scope,
+ ResourceGroup? parent,
+ string name,
+ string version = DefaultVersion,
+ AzureLocation? location = default,
+ bool isExisting = false,
+ Func? creator = null)
+ : base(scope, parent, name, ResourceTypeName, version, creator ?? Empty, isExisting)
+ {
+ }
+
+ ///
+ /// Creates a new instance of the class referencing an existing instance.
+ ///
+ /// The scope.
+ /// The resource name.
+ /// The resource group.
+ /// The KeyVault instance.
+ public static ApplicationInsightsComponent FromExisting(IConstruct scope, string name, ResourceGroup? parent = null)
+ => new ApplicationInsightsComponent(scope, parent: parent, name: name, isExisting: true);
+
+ ///
+ protected override string GetAzureName(IConstruct scope, string resourceName) => GetGloballyUniqueName(resourceName);
+ }
+}
diff --git a/sdk/provisioning/Azure.Provisioning/tests/Infrastructure/AppInsights/main.bicep b/sdk/provisioning/Azure.Provisioning/tests/Infrastructure/AppInsights/main.bicep
new file mode 100644
index 0000000000000..6f1e329d7ad80
--- /dev/null
+++ b/sdk/provisioning/Azure.Provisioning/tests/Infrastructure/AppInsights/main.bicep
@@ -0,0 +1,15 @@
+targetScope = 'resourceGroup'
+
+@description('')
+param location string = resourceGroup().location
+
+
+resource applicationInsightsComponent_FpLXFVEKV 'Microsoft.Insights/components@2020-02-02' = {
+ name: toLower(take(concat('appinsights', uniqueString(resourceGroup().id)), 24))
+ location: location
+ kind: 'web'
+ properties: {
+ Application_Type: 'web'
+ WorkspaceResourceId: 'workspaceId'
+ }
+}
diff --git a/sdk/provisioning/Azure.Provisioning/tests/Infrastructure/ExistingResources/resources/rg_TEST_module/rg_TEST_module.bicep b/sdk/provisioning/Azure.Provisioning/tests/Infrastructure/ExistingResources/resources/rg_TEST_module/rg_TEST_module.bicep
index 9aa0765294c49..feca39c398b5b 100644
--- a/sdk/provisioning/Azure.Provisioning/tests/Infrastructure/ExistingResources/resources/rg_TEST_module/rg_TEST_module.bicep
+++ b/sdk/provisioning/Azure.Provisioning/tests/Infrastructure/ExistingResources/resources/rg_TEST_module/rg_TEST_module.bicep
@@ -109,6 +109,10 @@ resource signalRService_d95Jninqk 'Microsoft.SignalRService/signalR@2022-02-01'
name: 'existingSignalR'
}
+resource applicationInsightsComponent_OdiSCimF0 'Microsoft.Insights/components@2020-02-02' existing = {
+ name: 'existingAppInsights'
+}
+
resource applicationSettingsResource_6DtpuGITF 'Microsoft.Web/sites/config@2021-02-01' = {
parent: webSite_C2Aq73IJb
name: 'appsettings'
diff --git a/sdk/provisioning/Azure.Provisioning/tests/ProvisioningTests.cs b/sdk/provisioning/Azure.Provisioning/tests/ProvisioningTests.cs
index 26918409dfd3c..b8177e23d450d 100644
--- a/sdk/provisioning/Azure.Provisioning/tests/ProvisioningTests.cs
+++ b/sdk/provisioning/Azure.Provisioning/tests/ProvisioningTests.cs
@@ -17,6 +17,7 @@
using Azure.Provisioning.Resources;
using Azure.Provisioning.Storage;
using Azure.Provisioning.AppConfiguration;
+using Azure.Provisioning.ApplicationInsights;
using Azure.Provisioning.Authorization;
using Azure.Provisioning.CognitiveServices;
using Azure.Provisioning.CosmosDB;
@@ -433,6 +434,18 @@ public async Task SignalR()
await ValidateBicepAsync(interactiveMode: true);
}
+ [RecordedTest]
+ public async Task AppInsights()
+ {
+ TestInfrastructure infrastructure = new TestInfrastructure(configuration: new Configuration { UseInteractiveMode = true });
+ var appInsights = new ApplicationInsightsComponent(infrastructure);
+ appInsights.Properties.WorkspaceResourceId = "workspaceId";
+
+ infrastructure.Build(GetOutputPath());
+
+ await ValidateBicepAsync(interactiveMode: true);
+ }
+
[RecordedTest]
public async Task WebSiteUsingL2()
{
@@ -767,6 +780,8 @@ public async Task ExistingResources()
infra.AddResource(SignalRService.FromExisting(infra, "'existingSignalR'", rg));
+ infra.AddResource(ApplicationInsightsComponent.FromExisting(infra, "'existingAppInsights'", rg));
+
infra.Build(GetOutputPath());
await ValidateBicepAsync(BinaryData.FromObjectAsJson(