From c3a232ba1fec15df76e99bb1246223d5c8a2469a Mon Sep 17 00:00:00 2001 From: m-nash <64171366+m-nash@users.noreply.github.com> Date: Thu, 15 Feb 2024 12:15:39 -0800 Subject: [PATCH] add support for appconfiguration --- eng/Packages.Data.props | 1 + .../api/Azure.Provisioning.net6.0.cs | 12 +++++ .../api/Azure.Provisioning.netstandard2.0.cs | 12 +++++ .../src/Azure.Provisioning.csproj | 1 + .../AppConfigurationExtensions.cs | 22 +++++++++ .../appconfiguration/AppConfigurationStore.cs | 46 +++++++++++++++++++ .../AppConfiguration/main.bicep | 21 +++++++++ .../tests/ProvisioningTests.cs | 9 ++++ 8 files changed, 124 insertions(+) create mode 100644 sdk/provisioning/Azure.Provisioning/src/appconfiguration/AppConfigurationExtensions.cs create mode 100644 sdk/provisioning/Azure.Provisioning/src/appconfiguration/AppConfigurationStore.cs create mode 100644 sdk/provisioning/Azure.Provisioning/tests/Infrastructure/AppConfiguration/main.bicep diff --git a/eng/Packages.Data.props b/eng/Packages.Data.props index f439e030daf6d..ce41c7e788514 100644 --- a/eng/Packages.Data.props +++ b/eng/Packages.Data.props @@ -134,6 +134,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 5094694d9e053..5e171348c8a94 100644 --- a/sdk/provisioning/Azure.Provisioning/api/Azure.Provisioning.net6.0.cs +++ b/sdk/provisioning/Azure.Provisioning/api/Azure.Provisioning.net6.0.cs @@ -100,6 +100,18 @@ public abstract partial class Resource : Azure.Provisioning.Resource where T public void AssignParameter(System.Linq.Expressions.Expression> propertySelector, Azure.Provisioning.Parameter parameter) { } } } +namespace Azure.Provisioning.AppConfiguration +{ + public static partial class AppConfigurationExtensions + { + public static Azure.Provisioning.AppConfiguration.AppConfigurationStore AddAppConfigurationStore(this Azure.Provisioning.IConstruct construct, string name = "store") { throw null; } + } + public partial class AppConfigurationStore : Azure.Provisioning.Resource + { + public AppConfigurationStore(Azure.Provisioning.IConstruct scope, string name = "store", string version = "2023-03-01", 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)) { } + protected override Azure.Provisioning.Resource? FindParentInScope(Azure.Provisioning.IConstruct scope) { 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 5094694d9e053..5e171348c8a94 100644 --- a/sdk/provisioning/Azure.Provisioning/api/Azure.Provisioning.netstandard2.0.cs +++ b/sdk/provisioning/Azure.Provisioning/api/Azure.Provisioning.netstandard2.0.cs @@ -100,6 +100,18 @@ public abstract partial class Resource : Azure.Provisioning.Resource where T public void AssignParameter(System.Linq.Expressions.Expression> propertySelector, Azure.Provisioning.Parameter parameter) { } } } +namespace Azure.Provisioning.AppConfiguration +{ + public static partial class AppConfigurationExtensions + { + public static Azure.Provisioning.AppConfiguration.AppConfigurationStore AddAppConfigurationStore(this Azure.Provisioning.IConstruct construct, string name = "store") { throw null; } + } + public partial class AppConfigurationStore : Azure.Provisioning.Resource + { + public AppConfigurationStore(Azure.Provisioning.IConstruct scope, string name = "store", string version = "2023-03-01", 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)) { } + protected override Azure.Provisioning.Resource? FindParentInScope(Azure.Provisioning.IConstruct scope) { throw null; } + } +} namespace Azure.Provisioning.AppService { public partial class AppServicePlan : Azure.Provisioning.Resource diff --git a/sdk/provisioning/Azure.Provisioning/src/Azure.Provisioning.csproj b/sdk/provisioning/Azure.Provisioning/src/Azure.Provisioning.csproj index 63f054a28e99a..b8aaee0356391 100644 --- a/sdk/provisioning/Azure.Provisioning/src/Azure.Provisioning.csproj +++ b/sdk/provisioning/Azure.Provisioning/src/Azure.Provisioning.csproj @@ -15,6 +15,7 @@ + diff --git a/sdk/provisioning/Azure.Provisioning/src/appconfiguration/AppConfigurationExtensions.cs b/sdk/provisioning/Azure.Provisioning/src/appconfiguration/AppConfigurationExtensions.cs new file mode 100644 index 0000000000000..13bcf6d79f0d0 --- /dev/null +++ b/sdk/provisioning/Azure.Provisioning/src/appconfiguration/AppConfigurationExtensions.cs @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +namespace Azure.Provisioning.AppConfiguration +{ + /// + /// Extension methods for . + /// + public static class AppConfigurationExtensions + { + /// + /// Adds a to the construct. + /// + /// The construct. + /// The name. + /// + public static AppConfigurationStore AddAppConfigurationStore(this IConstruct construct, string name = "store") + { + return new AppConfigurationStore(construct, name); + } + } +} diff --git a/sdk/provisioning/Azure.Provisioning/src/appconfiguration/AppConfigurationStore.cs b/sdk/provisioning/Azure.Provisioning/src/appconfiguration/AppConfigurationStore.cs new file mode 100644 index 0000000000000..c9cc184e744d7 --- /dev/null +++ b/sdk/provisioning/Azure.Provisioning/src/appconfiguration/AppConfigurationStore.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Azure.Core; +using Azure.Provisioning.ResourceManager; +using Azure.ResourceManager.AppConfiguration; +using Azure.ResourceManager.AppConfiguration.Models; + +namespace Azure.Provisioning.AppConfiguration +{ + /// + /// Represents a KeyVault. + /// + public class AppConfigurationStore : Resource + { + private const string ResourceTypeName = "Microsoft.AppConfiguration/configurationStores"; + + /// + /// Initializes a new instance of the class. + /// + /// The scope. + /// The name. + /// The version. + /// The location. + public AppConfigurationStore(IConstruct scope, string name = "store", string version = "2023-03-01", AzureLocation? location = default) + : base(scope, null, name, ResourceTypeName, version, (name) => ArmAppConfigurationModelFactory.AppConfigurationStoreData( + name: name, + resourceType: ResourceTypeName, + location: location ?? Environment.GetEnvironmentVariable("AZURE_LOCATION") ?? AzureLocation.WestUS, + skuName: "free")) + { + } + + /// + protected override Resource? FindParentInScope(IConstruct scope) + { + var result = base.FindParentInScope(scope); + if (result is null) + { + result = scope.GetOrAddResourceGroup(); + } + return result; + } + } +} diff --git a/sdk/provisioning/Azure.Provisioning/tests/Infrastructure/AppConfiguration/main.bicep b/sdk/provisioning/Azure.Provisioning/tests/Infrastructure/AppConfiguration/main.bicep new file mode 100644 index 0000000000000..48aeda971d698 --- /dev/null +++ b/sdk/provisioning/Azure.Provisioning/tests/Infrastructure/AppConfiguration/main.bicep @@ -0,0 +1,21 @@ +targetScope = subscription + + +resource resourceGroup_I6QNkoPsb 'Microsoft.Resources/resourceGroups@2023-07-01' = { + name: 'rg-TEST' + location: 'westus' + tags: { + azd-env-name: 'TEST' + } +} + +resource appConfigurationStore_sgecYnln3 'Microsoft.AppConfiguration/configurationStores@2023-03-01' = { + scope: resourceGroup_I6QNkoPsb + name: 'store-TEST' + location: 'westus' + sku: { + name: 'free' + } + properties: { + } +} diff --git a/sdk/provisioning/Azure.Provisioning/tests/ProvisioningTests.cs b/sdk/provisioning/Azure.Provisioning/tests/ProvisioningTests.cs index 6a99870be8659..cb7ae6103fcc1 100644 --- a/sdk/provisioning/Azure.Provisioning/tests/ProvisioningTests.cs +++ b/sdk/provisioning/Azure.Provisioning/tests/ProvisioningTests.cs @@ -11,6 +11,7 @@ using Azure.Provisioning.Sql; using Azure.Provisioning.Resources; using Azure.Provisioning.Storage; +using Azure.Provisioning.AppConfiguration; using Azure.ResourceManager.Storage.Models; namespace Azure.Provisioning.Tests @@ -120,6 +121,14 @@ public void StorageBlobDropDown() infra.Build(GetOutputPath()); } + [Test] + public void AppConfiguration() + { + var infra = new TestInfrastructure(); + infra.AddAppConfigurationStore(); + infra.Build(GetOutputPath()); + } + private static string GetGitRoot() { ProcessStartInfo startInfo = new ProcessStartInfo