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 64a18ef5c8736..c7a2e120a8fb1 100644 --- a/sdk/provisioning/Azure.Provisioning/api/Azure.Provisioning.net6.0.cs +++ b/sdk/provisioning/Azure.Provisioning/api/Azure.Provisioning.net6.0.cs @@ -125,14 +125,16 @@ public partial class AppConfigurationStore : Azure.Provisioning.Resource)) { } protected override Azure.Provisioning.Resource? FindParentInScope(Azure.Provisioning.IConstruct scope) { throw null; } + public static Azure.Provisioning.AppConfiguration.AppConfigurationStore FromExisting(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.ResourceManager.ResourceGroup? parent = null) { throw null; } } } namespace Azure.Provisioning.AppService { public partial class AppServicePlan : Azure.Provisioning.Resource { - public AppServicePlan(Azure.Provisioning.IConstruct scope, string resourceName, string version = "2021-02-01", Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?), Azure.Provisioning.ResourceManager.ResourceGroup? parent = null) : base (default(Azure.Provisioning.IConstruct), default(Azure.Provisioning.Resource), default(string), default(Azure.Core.ResourceType), default(string), default(System.Func)) { } + public AppServicePlan(Azure.Provisioning.IConstruct scope, string name, string version = "2021-02-01", Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?), Azure.Provisioning.ResourceManager.ResourceGroup? parent = null) : 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; } + public static Azure.Provisioning.AppService.AppServicePlan FromExisting(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.ResourceManager.ResourceGroup? parent = null) { throw null; } } public static partial class AppServicesExtensions { @@ -140,20 +142,23 @@ public static partial class AppServicesExtensions } public partial class WebSite : Azure.Provisioning.Resource { - public WebSite(Azure.Provisioning.IConstruct scope, string resourceName, Azure.Provisioning.AppService.AppServicePlan appServicePlan, Azure.Provisioning.AppService.WebSiteRuntime runtime, string runtimeVersion, string version = "2021-02-01", Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?), Azure.Provisioning.ResourceManager.ResourceGroup? parent = null) : base (default(Azure.Provisioning.IConstruct), default(Azure.Provisioning.Resource), default(string), default(Azure.Core.ResourceType), default(string), default(System.Func)) { } + public WebSite(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.AppService.AppServicePlan appServicePlan, Azure.Provisioning.AppService.WebSiteRuntime runtime, string runtimeVersion, string version = "2021-02-01", Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?), Azure.Provisioning.ResourceManager.ResourceGroup? parent = null) : base (default(Azure.Provisioning.IConstruct), default(Azure.Provisioning.Resource), default(string), default(Azure.Core.ResourceType), default(string), default(System.Func)) { } public void AddApplicationSetting(string key, Azure.Provisioning.Parameter value) { } public void AddApplicationSetting(string key, string value) { } public void AddLogConfig(string resourceName) { } protected override Azure.Provisioning.Resource? FindParentInScope(Azure.Provisioning.IConstruct scope) { throw null; } + public static Azure.Provisioning.AppService.WebSite FromExisting(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.ResourceManager.ResourceGroup? parent = null) { throw null; } } public partial class WebSiteConfigLogs : Azure.Provisioning.Resource { - public WebSiteConfigLogs(Azure.Provisioning.IConstruct scope, string resourceName, Azure.Provisioning.AppService.WebSite? parent = null, string version = "2021-02-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)) { } + public WebSiteConfigLogs(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.AppService.WebSite? parent = null, string version = "2021-02-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)) { } + public static Azure.Provisioning.AppService.WebSiteConfigLogs FromExisting(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.AppService.WebSite? parent = null) { throw null; } protected override string GetAzureName(Azure.Provisioning.IConstruct scope, string resourceName) { throw null; } } public partial class WebSitePublishingCredentialPolicy : Azure.Provisioning.Resource { - public WebSitePublishingCredentialPolicy(Azure.Provisioning.IConstruct scope, string resourceName, string version = "2021-02-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)) { } + public WebSitePublishingCredentialPolicy(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.AppService.WebSite? parent = null, string version = "2021-02-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)) { } + public static Azure.Provisioning.AppService.WebSitePublishingCredentialPolicy FromExisting(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.AppService.WebSite? parent = null) { throw null; } } public enum WebSiteRuntime { @@ -213,6 +218,7 @@ public partial class KeyVaultSecret : Azure.Provisioning.Resource)) { } public KeyVaultSecret(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.ConnectionString connectionString, Azure.Provisioning.KeyVaults.KeyVault? parent = null, string version = "2023-02-01") : 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; } + public static Azure.Provisioning.KeyVaults.KeyVaultSecret FromExisting(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.KeyVaults.KeyVault? parent = null) { throw null; } } } namespace Azure.Provisioning.PostgreSql @@ -225,6 +231,7 @@ public partial class PostgreSqlFlexibleServer : Azure.Provisioning.Resource)) { } protected override Azure.Provisioning.Resource? FindParentInScope(Azure.Provisioning.IConstruct scope) { throw null; } + public static Azure.Provisioning.PostgreSql.PostgreSqlFlexibleServer 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; } public Azure.Provisioning.PostgreSql.PostgreSqlConnectionString GetConnectionString(Azure.Provisioning.Parameter administratorLogin, Azure.Provisioning.Parameter administratorPassword) { throw null; } } @@ -235,6 +242,7 @@ public partial class RedisCache : Azure.Provisioning.Resource)) { } protected override Azure.Provisioning.Resource? FindParentInScope(Azure.Provisioning.IConstruct scope) { throw null; } + public static Azure.Provisioning.Redis.RedisCache 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; } public Azure.Provisioning.Redis.RedisCacheConnectionString GetConnectionString(bool useSecondary = false) { throw null; } } @@ -275,6 +283,7 @@ public partial class DeploymentScript : Azure.Provisioning.Resource)) { } public DeploymentScript(Azure.Provisioning.IConstruct scope, string resourceName, System.Collections.Generic.IEnumerable scriptEnvironmentVariables, string scriptContent, string version = "2020-10-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; } + public static Azure.Provisioning.Resources.DeploymentScript FromExisting(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.ResourceManager.ResourceGroup? parent = null) { throw null; } } } namespace Azure.Provisioning.Sql @@ -283,6 +292,7 @@ public partial class SqlDatabase : Azure.Provisioning.Resource)) { } protected override Azure.Provisioning.Resource? FindParentInScope(Azure.Provisioning.IConstruct scope) { throw null; } + public static Azure.Provisioning.Sql.SqlDatabase FromExisting(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.Sql.SqlServer? parent = null) { throw null; } public Azure.Provisioning.Sql.SqlDatabaseConnectionString GetConnectionString(Azure.Provisioning.Parameter passwordSecret, string userName = "appUser") { throw null; } } public partial class SqlDatabaseConnectionString : Azure.Provisioning.ConnectionString @@ -293,11 +303,13 @@ public partial class SqlFirewallRule : Azure.Provisioning.Resource)) { } protected override Azure.Provisioning.Resource? FindParentInScope(Azure.Provisioning.IConstruct scope) { throw null; } + public static Azure.Provisioning.Sql.SqlFirewallRule FromExisting(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.Sql.SqlServer? parent = null) { throw null; } } public partial class SqlServer : Azure.Provisioning.Resource { - public SqlServer(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.Parameter? adminLogin = default(Azure.Provisioning.Parameter?), Azure.Provisioning.Parameter? adminPassword = default(Azure.Provisioning.Parameter?), Azure.Provisioning.Sql.SqlServerAdministrator? administrator = default(Azure.Provisioning.Sql.SqlServerAdministrator?), string version = "2022-08-01-preview", 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 SqlServer(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.ResourceManager.ResourceGroup? parent = null, Azure.Provisioning.Parameter? adminLogin = default(Azure.Provisioning.Parameter?), Azure.Provisioning.Parameter? adminPassword = default(Azure.Provisioning.Parameter?), Azure.Provisioning.Sql.SqlServerAdministrator? administrator = default(Azure.Provisioning.Sql.SqlServerAdministrator?), string version = "2022-08-01-preview", 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; } + public static Azure.Provisioning.Sql.SqlServer 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; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] @@ -312,13 +324,15 @@ namespace Azure.Provisioning.Storage { public partial class BlobService : Azure.Provisioning.Resource { - public BlobService(Azure.Provisioning.IConstruct scope) : base (default(Azure.Provisioning.IConstruct), default(Azure.Provisioning.Resource), default(string), default(Azure.Core.ResourceType), default(string), default(System.Func)) { } + public BlobService(Azure.Provisioning.IConstruct scope, Azure.Provisioning.Storage.StorageAccount? parent = null) : 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; } + public static Azure.Provisioning.Storage.BlobService FromExisting(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.Storage.StorageAccount? parent = null) { throw null; } } public partial class StorageAccount : Azure.Provisioning.Resource { public StorageAccount(Azure.Provisioning.IConstruct scope, Azure.ResourceManager.Storage.Models.StorageKind kind, Azure.ResourceManager.Storage.Models.StorageSkuName sku, Azure.Provisioning.ResourceManager.ResourceGroup? parent = null, string name = "sa") : 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; } + public static Azure.Provisioning.Storage.StorageAccount 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; } } public static partial class StorageExtensions 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 64a18ef5c8736..c7a2e120a8fb1 100644 --- a/sdk/provisioning/Azure.Provisioning/api/Azure.Provisioning.netstandard2.0.cs +++ b/sdk/provisioning/Azure.Provisioning/api/Azure.Provisioning.netstandard2.0.cs @@ -125,14 +125,16 @@ public partial class AppConfigurationStore : Azure.Provisioning.Resource)) { } protected override Azure.Provisioning.Resource? FindParentInScope(Azure.Provisioning.IConstruct scope) { throw null; } + public static Azure.Provisioning.AppConfiguration.AppConfigurationStore FromExisting(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.ResourceManager.ResourceGroup? parent = null) { throw null; } } } namespace Azure.Provisioning.AppService { public partial class AppServicePlan : Azure.Provisioning.Resource { - public AppServicePlan(Azure.Provisioning.IConstruct scope, string resourceName, string version = "2021-02-01", Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?), Azure.Provisioning.ResourceManager.ResourceGroup? parent = null) : base (default(Azure.Provisioning.IConstruct), default(Azure.Provisioning.Resource), default(string), default(Azure.Core.ResourceType), default(string), default(System.Func)) { } + public AppServicePlan(Azure.Provisioning.IConstruct scope, string name, string version = "2021-02-01", Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?), Azure.Provisioning.ResourceManager.ResourceGroup? parent = null) : 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; } + public static Azure.Provisioning.AppService.AppServicePlan FromExisting(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.ResourceManager.ResourceGroup? parent = null) { throw null; } } public static partial class AppServicesExtensions { @@ -140,20 +142,23 @@ public static partial class AppServicesExtensions } public partial class WebSite : Azure.Provisioning.Resource { - public WebSite(Azure.Provisioning.IConstruct scope, string resourceName, Azure.Provisioning.AppService.AppServicePlan appServicePlan, Azure.Provisioning.AppService.WebSiteRuntime runtime, string runtimeVersion, string version = "2021-02-01", Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?), Azure.Provisioning.ResourceManager.ResourceGroup? parent = null) : base (default(Azure.Provisioning.IConstruct), default(Azure.Provisioning.Resource), default(string), default(Azure.Core.ResourceType), default(string), default(System.Func)) { } + public WebSite(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.AppService.AppServicePlan appServicePlan, Azure.Provisioning.AppService.WebSiteRuntime runtime, string runtimeVersion, string version = "2021-02-01", Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?), Azure.Provisioning.ResourceManager.ResourceGroup? parent = null) : base (default(Azure.Provisioning.IConstruct), default(Azure.Provisioning.Resource), default(string), default(Azure.Core.ResourceType), default(string), default(System.Func)) { } public void AddApplicationSetting(string key, Azure.Provisioning.Parameter value) { } public void AddApplicationSetting(string key, string value) { } public void AddLogConfig(string resourceName) { } protected override Azure.Provisioning.Resource? FindParentInScope(Azure.Provisioning.IConstruct scope) { throw null; } + public static Azure.Provisioning.AppService.WebSite FromExisting(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.ResourceManager.ResourceGroup? parent = null) { throw null; } } public partial class WebSiteConfigLogs : Azure.Provisioning.Resource { - public WebSiteConfigLogs(Azure.Provisioning.IConstruct scope, string resourceName, Azure.Provisioning.AppService.WebSite? parent = null, string version = "2021-02-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)) { } + public WebSiteConfigLogs(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.AppService.WebSite? parent = null, string version = "2021-02-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)) { } + public static Azure.Provisioning.AppService.WebSiteConfigLogs FromExisting(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.AppService.WebSite? parent = null) { throw null; } protected override string GetAzureName(Azure.Provisioning.IConstruct scope, string resourceName) { throw null; } } public partial class WebSitePublishingCredentialPolicy : Azure.Provisioning.Resource { - public WebSitePublishingCredentialPolicy(Azure.Provisioning.IConstruct scope, string resourceName, string version = "2021-02-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)) { } + public WebSitePublishingCredentialPolicy(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.AppService.WebSite? parent = null, string version = "2021-02-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)) { } + public static Azure.Provisioning.AppService.WebSitePublishingCredentialPolicy FromExisting(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.AppService.WebSite? parent = null) { throw null; } } public enum WebSiteRuntime { @@ -213,6 +218,7 @@ public partial class KeyVaultSecret : Azure.Provisioning.Resource)) { } public KeyVaultSecret(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.ConnectionString connectionString, Azure.Provisioning.KeyVaults.KeyVault? parent = null, string version = "2023-02-01") : 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; } + public static Azure.Provisioning.KeyVaults.KeyVaultSecret FromExisting(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.KeyVaults.KeyVault? parent = null) { throw null; } } } namespace Azure.Provisioning.PostgreSql @@ -225,6 +231,7 @@ public partial class PostgreSqlFlexibleServer : Azure.Provisioning.Resource)) { } protected override Azure.Provisioning.Resource? FindParentInScope(Azure.Provisioning.IConstruct scope) { throw null; } + public static Azure.Provisioning.PostgreSql.PostgreSqlFlexibleServer 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; } public Azure.Provisioning.PostgreSql.PostgreSqlConnectionString GetConnectionString(Azure.Provisioning.Parameter administratorLogin, Azure.Provisioning.Parameter administratorPassword) { throw null; } } @@ -235,6 +242,7 @@ public partial class RedisCache : Azure.Provisioning.Resource)) { } protected override Azure.Provisioning.Resource? FindParentInScope(Azure.Provisioning.IConstruct scope) { throw null; } + public static Azure.Provisioning.Redis.RedisCache 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; } public Azure.Provisioning.Redis.RedisCacheConnectionString GetConnectionString(bool useSecondary = false) { throw null; } } @@ -275,6 +283,7 @@ public partial class DeploymentScript : Azure.Provisioning.Resource)) { } public DeploymentScript(Azure.Provisioning.IConstruct scope, string resourceName, System.Collections.Generic.IEnumerable scriptEnvironmentVariables, string scriptContent, string version = "2020-10-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; } + public static Azure.Provisioning.Resources.DeploymentScript FromExisting(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.ResourceManager.ResourceGroup? parent = null) { throw null; } } } namespace Azure.Provisioning.Sql @@ -283,6 +292,7 @@ public partial class SqlDatabase : Azure.Provisioning.Resource)) { } protected override Azure.Provisioning.Resource? FindParentInScope(Azure.Provisioning.IConstruct scope) { throw null; } + public static Azure.Provisioning.Sql.SqlDatabase FromExisting(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.Sql.SqlServer? parent = null) { throw null; } public Azure.Provisioning.Sql.SqlDatabaseConnectionString GetConnectionString(Azure.Provisioning.Parameter passwordSecret, string userName = "appUser") { throw null; } } public partial class SqlDatabaseConnectionString : Azure.Provisioning.ConnectionString @@ -293,11 +303,13 @@ public partial class SqlFirewallRule : Azure.Provisioning.Resource)) { } protected override Azure.Provisioning.Resource? FindParentInScope(Azure.Provisioning.IConstruct scope) { throw null; } + public static Azure.Provisioning.Sql.SqlFirewallRule FromExisting(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.Sql.SqlServer? parent = null) { throw null; } } public partial class SqlServer : Azure.Provisioning.Resource { - public SqlServer(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.Parameter? adminLogin = default(Azure.Provisioning.Parameter?), Azure.Provisioning.Parameter? adminPassword = default(Azure.Provisioning.Parameter?), Azure.Provisioning.Sql.SqlServerAdministrator? administrator = default(Azure.Provisioning.Sql.SqlServerAdministrator?), string version = "2022-08-01-preview", 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 SqlServer(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.ResourceManager.ResourceGroup? parent = null, Azure.Provisioning.Parameter? adminLogin = default(Azure.Provisioning.Parameter?), Azure.Provisioning.Parameter? adminPassword = default(Azure.Provisioning.Parameter?), Azure.Provisioning.Sql.SqlServerAdministrator? administrator = default(Azure.Provisioning.Sql.SqlServerAdministrator?), string version = "2022-08-01-preview", 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; } + public static Azure.Provisioning.Sql.SqlServer 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; } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] @@ -312,13 +324,15 @@ namespace Azure.Provisioning.Storage { public partial class BlobService : Azure.Provisioning.Resource { - public BlobService(Azure.Provisioning.IConstruct scope) : base (default(Azure.Provisioning.IConstruct), default(Azure.Provisioning.Resource), default(string), default(Azure.Core.ResourceType), default(string), default(System.Func)) { } + public BlobService(Azure.Provisioning.IConstruct scope, Azure.Provisioning.Storage.StorageAccount? parent = null) : 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; } + public static Azure.Provisioning.Storage.BlobService FromExisting(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.Storage.StorageAccount? parent = null) { throw null; } } public partial class StorageAccount : Azure.Provisioning.Resource { public StorageAccount(Azure.Provisioning.IConstruct scope, Azure.ResourceManager.Storage.Models.StorageKind kind, Azure.ResourceManager.Storage.Models.StorageSkuName sku, Azure.Provisioning.ResourceManager.ResourceGroup? parent = null, string name = "sa") : 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; } + public static Azure.Provisioning.Storage.StorageAccount 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; } } public static partial class StorageExtensions diff --git a/sdk/provisioning/Azure.Provisioning/src/ModuleConstruct.cs b/sdk/provisioning/Azure.Provisioning/src/ModuleConstruct.cs index 9a1863986598d..2477401d35d97 100644 --- a/sdk/provisioning/Azure.Provisioning/src/ModuleConstruct.cs +++ b/sdk/provisioning/Azure.Provisioning/src/ModuleConstruct.cs @@ -147,7 +147,7 @@ private void WriteExistingResources(MemoryStream stream) { stream.WriteLine(); stream.WriteLine($"resource {resource.Name} '{resource.Id.ResourceType}@{resource.Version}' existing = {{"); - stream.WriteLine($" name: '{resource.Id.Name}'"); + stream.WriteLine($" name: {resource.Id.Name}"); stream.WriteLine($"}}"); } } diff --git a/sdk/provisioning/Azure.Provisioning/src/appconfiguration/AppConfigurationStore.cs b/sdk/provisioning/Azure.Provisioning/src/appconfiguration/AppConfigurationStore.cs index b657c4f039023..8b52da4625372 100644 --- a/sdk/provisioning/Azure.Provisioning/src/appconfiguration/AppConfigurationStore.cs +++ b/sdk/provisioning/Azure.Provisioning/src/appconfiguration/AppConfigurationStore.cs @@ -15,6 +15,7 @@ namespace Azure.Provisioning.AppConfiguration public class AppConfigurationStore : Resource { private const string ResourceTypeName = "Microsoft.AppConfiguration/configurationStores"; + private static readonly Func Empty = (name) => ArmAppConfigurationModelFactory.AppConfigurationStoreData(); /// /// Initializes a new instance of the class. @@ -24,7 +25,7 @@ public class AppConfigurationStore : Resource /// 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( + : this(scope, name, version, location, null, false, (name) => ArmAppConfigurationModelFactory.AppConfigurationStoreData( name: name, resourceType: ResourceTypeName, location: location ?? Environment.GetEnvironmentVariable("AZURE_LOCATION") ?? AzureLocation.WestUS, @@ -33,6 +34,21 @@ public AppConfigurationStore(IConstruct scope, string name = "store", string ver AddOutput(store => store.Endpoint, $"{Name}_endpoint"); } + private AppConfigurationStore(IConstruct scope, string name = "store", string version = "2023-03-01", AzureLocation? location = default, ResourceGroup? parent = null, bool isExisting = false, Func? creator = null) + : base(scope, null, 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 AppConfigurationStore FromExisting(IConstruct scope, string name, ResourceGroup? parent = null) + => new AppConfigurationStore(scope, name, parent: parent, isExisting: true); + /// protected override Resource? FindParentInScope(IConstruct scope) { diff --git a/sdk/provisioning/Azure.Provisioning/src/keyvault/KeyVault.cs b/sdk/provisioning/Azure.Provisioning/src/keyvault/KeyVault.cs index cc6907af16418..8f923e1525800 100644 --- a/sdk/provisioning/Azure.Provisioning/src/keyvault/KeyVault.cs +++ b/sdk/provisioning/Azure.Provisioning/src/keyvault/KeyVault.cs @@ -16,9 +16,10 @@ namespace Azure.Provisioning.KeyVaults public class KeyVault : Resource { private const string ResourceTypeName = "Microsoft.KeyVault/vaults"; + private static readonly Func Empty = (name) => ArmKeyVaultModelFactory.KeyVaultData(); /// - /// Creates a new instance of the class referencing an existing KeyVault. + /// Creates a new instance of the class referencing an existing instance. /// /// The scope. /// The resource name. @@ -36,12 +37,7 @@ public static KeyVault FromExisting(IConstruct scope, string name, ResourceGroup /// The location. /// public KeyVault(IConstruct scope, ResourceGroup? parent = default, string name = "kv", string version = "2023-02-01", AzureLocation? location = default) - : this(scope, parent, name, version, location, false) - { - } - - private KeyVault(IConstruct scope, ResourceGroup? parent = default, string name = "kv", string version = "2023-02-01", AzureLocation? location = default, bool isExisting = false) - : base(scope, parent, name, ResourceTypeName, version, (name) => ArmKeyVaultModelFactory.KeyVaultData( + : this(scope, parent, name, version, location, false, (name) => ArmKeyVaultModelFactory.KeyVaultData( name: name, resourceType: ResourceTypeName, location: location ?? Environment.GetEnvironmentVariable("AZURE_LOCATION") ?? AzureLocation.WestUS, @@ -58,20 +54,21 @@ private KeyVault(IConstruct scope, ResourceGroup? parent = default, string name } }) } : default, - enableRbacAuthorization: true)), - isExisting: isExisting) + enableRbacAuthorization: true))) { - if (!isExisting) - { - AssignProperty(data => data.Name, GetAzureName(scope, name)); + AssignProperty(data => data.Name, GetAzureName(scope, name)); - if (scope.Root.Properties.TenantId == Guid.Empty) - { - AssignProperty(kv => kv.Properties.TenantId, Tenant.TenantIdExpression); - } + if (scope.Root.Properties.TenantId == Guid.Empty) + { + AssignProperty(kv => kv.Properties.TenantId, Tenant.TenantIdExpression); } } + private KeyVault(IConstruct scope, ResourceGroup? parent = default, string name = "kv", string version = "2023-02-01", AzureLocation? location = default, bool isExisting = false, Func? creator = null) + : base(scope, parent, name, ResourceTypeName, version, creator ?? Empty, isExisting: isExisting) + { + } + /// /// Adds an access policy to the . /// diff --git a/sdk/provisioning/Azure.Provisioning/src/keyvault/KeyVaultSecret.cs b/sdk/provisioning/Azure.Provisioning/src/keyvault/KeyVaultSecret.cs index 49906e5184de3..738ad5cac6fdf 100644 --- a/sdk/provisioning/Azure.Provisioning/src/keyvault/KeyVaultSecret.cs +++ b/sdk/provisioning/Azure.Provisioning/src/keyvault/KeyVaultSecret.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using Azure.Provisioning.Sql; using Azure.ResourceManager.KeyVault; using Azure.ResourceManager.KeyVault.Models; @@ -14,6 +13,7 @@ namespace Azure.Provisioning.KeyVaults public class KeyVaultSecret : Resource { private const string ResourceTypeName = "Microsoft.KeyVault/vaults/secrets"; + private static readonly Func Empty = (name) => ArmKeyVaultModelFactory.KeyVaultSecretData(); /// /// Initializes a new instance of the . @@ -23,7 +23,7 @@ public class KeyVaultSecret : Resource /// The name. /// The version. public KeyVaultSecret(IConstruct scope, KeyVault? parent = null, string name = "kvs", string version = "2023-02-01") - : base(scope, parent, name, ResourceTypeName, version, (name) => ArmKeyVaultModelFactory.KeyVaultSecretData( + : this(scope, parent, name, version, false, (name) => ArmKeyVaultModelFactory.KeyVaultSecretData( name: name, resourceType: ResourceTypeName, properties: ArmKeyVaultModelFactory.SecretProperties( @@ -32,6 +32,11 @@ public KeyVaultSecret(IConstruct scope, KeyVault? parent = null, string name = " { } + private KeyVaultSecret(IConstruct scope, KeyVault? parent = null, string name = "kvs", string version = "2023-02-01", bool isExisting = false, Func? createProperties = null) + : base(scope, parent, name, ResourceTypeName, version, createProperties ?? Empty, isExisting) + { + } + /// /// Initializes a new instance of the . /// @@ -41,7 +46,7 @@ public KeyVaultSecret(IConstruct scope, KeyVault? parent = null, string name = " /// The connection string. /// The version. public KeyVaultSecret(IConstruct scope, string name, ConnectionString connectionString, KeyVault? parent = null, string version = "2023-02-01") - : base(scope, parent, name, ResourceTypeName, version, (name) => ArmKeyVaultModelFactory.KeyVaultSecretData( + : this(scope, parent, name, version, false, (name) => ArmKeyVaultModelFactory.KeyVaultSecretData( name: name, resourceType: ResourceTypeName, properties: ArmKeyVaultModelFactory.SecretProperties( @@ -50,6 +55,16 @@ public KeyVaultSecret(IConstruct scope, string name, ConnectionString connection { } + /// + /// Creates a new instance of the class referencing an existing instance. + /// + /// The scope. + /// The resource name. + /// The resource group. + /// The KeyVault instance. + public static KeyVaultSecret FromExisting(IConstruct scope, string name, KeyVault? parent = null) + => new KeyVaultSecret(scope, parent, name, isExisting: true); + /// protected override Resource? FindParentInScope(IConstruct scope) { diff --git a/sdk/provisioning/Azure.Provisioning/src/postgresql/PostgreSqlFlexibleServer.cs b/sdk/provisioning/Azure.Provisioning/src/postgresql/PostgreSqlFlexibleServer.cs index 71e7f71c094cd..6d1a93d994b42 100644 --- a/sdk/provisioning/Azure.Provisioning/src/postgresql/PostgreSqlFlexibleServer.cs +++ b/sdk/provisioning/Azure.Provisioning/src/postgresql/PostgreSqlFlexibleServer.cs @@ -5,11 +5,8 @@ using Azure.Core; using Azure.Provisioning.Redis; using Azure.Provisioning.ResourceManager; -using Azure.ResourceManager.PostgreSql; using Azure.ResourceManager.PostgreSql.FlexibleServers; using Azure.ResourceManager.PostgreSql.FlexibleServers.Models; -using Azure.ResourceManager.PostgreSql.Models; -using Azure.ResourceManager.Redis.Models; namespace Azure.Provisioning.PostgreSql { @@ -19,6 +16,7 @@ namespace Azure.Provisioning.PostgreSql public class PostgreSqlFlexibleServer : Resource { private const string ResourceTypeName = "Microsoft.DBforPostgreSQL/flexibleServers"; + private static readonly Func Empty = (name) => ArmPostgreSqlFlexibleServersModelFactory.PostgreSqlFlexibleServerData(); /// /// Creates a new instance of the class. @@ -50,7 +48,7 @@ public PostgreSqlFlexibleServer( string name = "postgres", string version = "2020-06-01", AzureLocation? location = default) - : base(scope, parent, name, ResourceTypeName, version, (name) => ArmPostgreSqlFlexibleServersModelFactory.PostgreSqlFlexibleServerData( + : this(scope, administratorLogin, administratorPassword, sku, highAvailability, storage, backup, network, availabilityZone, parent, name, version, location, false, (name) => ArmPostgreSqlFlexibleServersModelFactory.PostgreSqlFlexibleServerData( name: name, sku: sku, // create new instances so the properties can be overriden by user if needed @@ -66,6 +64,26 @@ public PostgreSqlFlexibleServer( AssignProperty(data => data.AdministratorLoginPassword, administratorPassword); } + private PostgreSqlFlexibleServer( + IConstruct scope, + Parameter administratorLogin = default, + Parameter administratorPassword = default, + PostgreSqlFlexibleServerSku? sku = default, + PostgreSqlFlexibleServerHighAvailability? highAvailability = default, + PostgreSqlFlexibleServerStorage? storage = default, + PostgreSqlFlexibleServerBackupProperties? backup = default, + PostgreSqlFlexibleServerNetwork? network = default, + string? availabilityZone = default, + ResourceGroup? parent = default, + string name = "postgres", + string version = "2020-06-01", + AzureLocation? location = default, + bool isExisting = false, + Func? creator = null) + : base(scope, parent, name, ResourceTypeName, version, creator ?? Empty, isExisting) + { + } + /// protected override Resource? FindParentInScope(IConstruct scope) { @@ -77,6 +95,16 @@ public PostgreSqlFlexibleServer( return result; } + /// + /// Creates a new instance of the class referencing an existing instance. + /// + /// The scope. + /// The resource name. + /// The resource group. + /// The KeyVault instance. + public static PostgreSqlFlexibleServer FromExisting(IConstruct scope, string name, ResourceGroup? parent = null) + => new PostgreSqlFlexibleServer(scope, parent: parent, name: name, isExisting: true); + /// /// Gets the connection string for the . /// diff --git a/sdk/provisioning/Azure.Provisioning/src/redis/RedisCache.cs b/sdk/provisioning/Azure.Provisioning/src/redis/RedisCache.cs index 8368280927654..d15fe4d13fa16 100644 --- a/sdk/provisioning/Azure.Provisioning/src/redis/RedisCache.cs +++ b/sdk/provisioning/Azure.Provisioning/src/redis/RedisCache.cs @@ -15,6 +15,7 @@ namespace Azure.Provisioning.Redis public class RedisCache : Resource { private const string ResourceTypeName = "Microsoft.Cache/Redis"; + private static readonly Func Empty = (name) => ArmRedisModelFactory.RedisData(updateChannel: null); /// /// Creates a new instance of the class. @@ -25,7 +26,7 @@ public class RedisCache : Resource /// /// public RedisCache(IConstruct scope, RedisSku? sku = default, ResourceGroup? parent = default, string name = "redis", AzureLocation? location = default) - : base(scope, parent, name, ResourceTypeName, "2020-06-01", (name) => ArmRedisModelFactory.RedisData( + : this(scope, sku, parent, name, location, false, (name) => ArmRedisModelFactory.RedisData( name: name, location: location ?? Environment.GetEnvironmentVariable("AZURE_LOCATION") ?? AzureLocation.WestUS, enableNonSslPort: false, @@ -37,6 +38,11 @@ public RedisCache(IConstruct scope, RedisSku? sku = default, ResourceGroup? pare AssignProperty(data => data.Name, GetAzureName(scope, name)); } + private RedisCache(IConstruct scope, RedisSku? sku = default, ResourceGroup? parent = default, string name = "redis", AzureLocation? location = default, bool isExisting = false, Func? creator = null) + : base(scope, parent, name, ResourceTypeName, "2020-06-01", creator ?? Empty, isExisting) + { + } + /// /// Gets the connection string for the . /// @@ -54,6 +60,16 @@ public RedisCacheConnectionString GetConnectionString(bool useSecondary = false) return result; } + /// + /// Creates a new instance of the class referencing an existing instance. + /// + /// The scope. + /// The resource name. + /// The resource group. + /// The KeyVault instance. + public static RedisCache FromExisting(IConstruct scope, string name, ResourceGroup? parent = null) + => new RedisCache(scope, parent: parent, name: name, isExisting: true); + /// protected override string GetAzureName(IConstruct scope, string resourceName) => GetGloballyUniqueName(resourceName); } diff --git a/sdk/provisioning/Azure.Provisioning/src/resources/DeploymentScript.cs b/sdk/provisioning/Azure.Provisioning/src/resources/DeploymentScript.cs index 52ff33e01656a..0e916c34c6652 100644 --- a/sdk/provisioning/Azure.Provisioning/src/resources/DeploymentScript.cs +++ b/sdk/provisioning/Azure.Provisioning/src/resources/DeploymentScript.cs @@ -16,6 +16,7 @@ public class DeploymentScript : Resource { private const string ResourceTypeName = "Microsoft.Resources/deploymentScripts"; private const string _defaultVersion = "2020-10-01"; + private static readonly Func Empty = (name) => ArmResourcesModelFactory.AzureCliScript(); /// /// Initializes a new instance of the . @@ -36,7 +37,8 @@ public DeploymentScript(IConstruct scope, string resourceName, IEnumerable data.EnvironmentVariables[0].SecureValue, appUserPasswordSecret); AssignProperty(data => data.EnvironmentVariables[1].SecureValue, sqlAdminPasswordSecret); AssignProperty(data => data.EnvironmentVariables[2].Value, databaseServerName); } + /// + /// Creates a new instance of the class referencing an existing instance. + /// + /// The scope. + /// The resource name. + /// The resource group. + /// The KeyVault instance. + public static DeploymentScript FromExisting(IConstruct scope, string name, ResourceGroup? parent = null) + => new DeploymentScript(scope, parent: parent, name: name, isExisting: true); + + private DeploymentScript(IConstruct scope, string name, ResourceGroup? parent = null, bool isExisting = false) + : base(scope, parent, name, ResourceTypeName, _defaultVersion, Empty, isExisting) + { + } + /// protected override Resource? FindParentInScope(IConstruct scope) { diff --git a/sdk/provisioning/Azure.Provisioning/src/sqlmanagement/SqlDatabase.cs b/sdk/provisioning/Azure.Provisioning/src/sqlmanagement/SqlDatabase.cs index 95bcaaa25aedd..e99b349bdf90a 100644 --- a/sdk/provisioning/Azure.Provisioning/src/sqlmanagement/SqlDatabase.cs +++ b/sdk/provisioning/Azure.Provisioning/src/sqlmanagement/SqlDatabase.cs @@ -14,6 +14,7 @@ namespace Azure.Provisioning.Sql public class SqlDatabase : Resource { private const string ResourceTypeName = "Microsoft.Sql/servers/databases"; + private static readonly Func Empty = (name) => ArmSqlModelFactory.SqlDatabaseData(); /// /// Initializes a new instance of the . @@ -24,12 +25,17 @@ public class SqlDatabase : Resource /// The version. /// The location. public SqlDatabase(IConstruct scope, SqlServer? parent = null, string name = "db", string version = "2022-08-01-preview", AzureLocation? location = default) - : base(scope, parent, name, ResourceTypeName, version, (name) => ArmSqlModelFactory.SqlDatabaseData( + : this(scope, parent, name, version, location, false, (name) => ArmSqlModelFactory.SqlDatabaseData( name: name, resourceType: ResourceTypeName)) { } + private SqlDatabase(IConstruct scope, SqlServer? parent = null, string name = "db", string version = "2022-08-01-preview", AzureLocation? location = default, bool isExisting = false, Func? creator = null) + : base(scope, parent, name, ResourceTypeName, version, creator ?? Empty, isExisting) + { + } + /// /// Gets the connection string for the . /// @@ -39,6 +45,16 @@ public SqlDatabase(IConstruct scope, SqlServer? parent = null, string name = "db public SqlDatabaseConnectionString GetConnectionString(Parameter passwordSecret, string userName = "appUser") => new SqlDatabaseConnectionString(this, passwordSecret, userName); + /// + /// Creates a new instance of the class referencing an existing instance. + /// + /// The scope. + /// The resource name. + /// The resource group. + /// The KeyVault instance. + public static SqlDatabase FromExisting(IConstruct scope, string name, SqlServer? parent = null) + => new SqlDatabase(scope, parent: parent, name: name, isExisting: true); + /// protected override Resource? FindParentInScope(IConstruct scope) { diff --git a/sdk/provisioning/Azure.Provisioning/src/sqlmanagement/SqlFirewallRule.cs b/sdk/provisioning/Azure.Provisioning/src/sqlmanagement/SqlFirewallRule.cs index 72ff35e46e777..103cc268f3f28 100644 --- a/sdk/provisioning/Azure.Provisioning/src/sqlmanagement/SqlFirewallRule.cs +++ b/sdk/provisioning/Azure.Provisioning/src/sqlmanagement/SqlFirewallRule.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using System; using Azure.ResourceManager.Sql; using Azure.ResourceManager.Sql.Models; @@ -12,6 +13,7 @@ namespace Azure.Provisioning.Sql public class SqlFirewallRule : Resource { private const string ResourceTypeName = "Microsoft.Sql/servers/firewallRules"; + private static readonly Func Empty = (name) => ArmSqlModelFactory.SqlFirewallRuleData(); /// /// Initializes a new instance of the . @@ -21,7 +23,7 @@ public class SqlFirewallRule : Resource /// The name. /// The version. public SqlFirewallRule(IConstruct scope, SqlServer? parent = default, string name = "fw", string version = "2020-11-01-preview") - : base(scope, parent, name, ResourceTypeName, version, (name) => ArmSqlModelFactory.SqlFirewallRuleData( + : this(scope, parent, name, version, false, (name) => ArmSqlModelFactory.SqlFirewallRuleData( name: name, resourceType: ResourceTypeName, startIPAddress: "0.0.0.1", @@ -30,6 +32,21 @@ public SqlFirewallRule(IConstruct scope, SqlServer? parent = default, string nam { } + private SqlFirewallRule(IConstruct scope, SqlServer? parent = default, string name = "fw", string version = "2020-11-01-preview", 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 SqlFirewallRule FromExisting(IConstruct scope, string name, SqlServer? parent = null) + => new SqlFirewallRule(scope, parent: parent, name: name, isExisting: true); + /// protected override Resource? FindParentInScope(IConstruct scope) { diff --git a/sdk/provisioning/Azure.Provisioning/src/sqlmanagement/SqlServer.cs b/sdk/provisioning/Azure.Provisioning/src/sqlmanagement/SqlServer.cs index 635aec0420170..ca5474067ef60 100644 --- a/sdk/provisioning/Azure.Provisioning/src/sqlmanagement/SqlServer.cs +++ b/sdk/provisioning/Azure.Provisioning/src/sqlmanagement/SqlServer.cs @@ -15,12 +15,14 @@ namespace Azure.Provisioning.Sql public class SqlServer : Resource { private const string ResourceTypeName = "Microsoft.Sql/servers"; + private static readonly Func Empty = (name) => ArmSqlModelFactory.SqlServerData(); /// /// Initializes a new instance of the class for mocking. /// /// The scope. /// The name. + /// The parent. /// The administrator login. /// The administrator password. /// The administrator when using Entra. @@ -29,12 +31,13 @@ public class SqlServer : Resource public SqlServer( IConstruct scope, string name, + ResourceGroup? parent = null, Parameter? adminLogin = default, Parameter? adminPassword = default, SqlServerAdministrator? administrator = default, string version = "2022-08-01-preview", AzureLocation? location = default) - : base(scope, null, name, ResourceTypeName, version, (name) => ArmSqlModelFactory.SqlServerData( + : this(scope, name, parent, adminLogin, adminPassword, administrator, version, location, false, (name) => ArmSqlModelFactory.SqlServerData( name: name, location: location ?? Environment.GetEnvironmentVariable("AZURE_LOCATION") ?? AzureLocation.WestUS, resourceType: ResourceTypeName, @@ -64,6 +67,31 @@ public SqlServer( } } + private SqlServer( + IConstruct scope, + string name, + ResourceGroup? parent = null, + Parameter? adminLogin = default, + Parameter? adminPassword = default, + SqlServerAdministrator? administrator = default, + string version = "2022-08-01-preview", + 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 SqlServer FromExisting(IConstruct scope, string name, ResourceGroup? parent = null) + => new SqlServer(scope, parent: parent, name: name, isExisting: true); + /// protected override Resource? FindParentInScope(IConstruct scope) { diff --git a/sdk/provisioning/Azure.Provisioning/src/storage/BlobService.cs b/sdk/provisioning/Azure.Provisioning/src/storage/BlobService.cs index 75d1623a1bd6b..c907f46012d8a 100644 --- a/sdk/provisioning/Azure.Provisioning/src/storage/BlobService.cs +++ b/sdk/provisioning/Azure.Provisioning/src/storage/BlobService.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using System; using Azure.ResourceManager.Storage; using Azure.ResourceManager.Storage.Models; @@ -12,18 +13,35 @@ namespace Azure.Provisioning.Storage public class BlobService : Resource { private const string ResourceTypeName = "Microsoft.Storage/storageAccounts/blobServices"; + private static readonly Func Empty = (name) => ArmStorageModelFactory.BlobServiceData(); /// /// Initializes a new instance of the . /// /// The scope. - public BlobService(IConstruct scope) - : base(scope, null, "default", ResourceTypeName, "2022-09-01", (name) => ArmStorageModelFactory.BlobServiceData( - name: "default", + /// The parent. + public BlobService(IConstruct scope, StorageAccount? parent = null) + : this(scope, parent, null, false, (name) => ArmStorageModelFactory.BlobServiceData( + name: name ?? "default", resourceType: ResourceTypeName)) { } + private BlobService(IConstruct scope, StorageAccount? parent = null, string? name = null, bool isExisting = false, Func? creator = null) + : base(scope, parent, name ?? "default", ResourceTypeName, "2022-09-01", 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 BlobService FromExisting(IConstruct scope, string name, StorageAccount? parent = null) + => new BlobService(scope, parent: parent, name: name, isExisting: true); + /// protected override Resource? FindParentInScope(IConstruct scope) { diff --git a/sdk/provisioning/Azure.Provisioning/src/storage/StorageAccount.cs b/sdk/provisioning/Azure.Provisioning/src/storage/StorageAccount.cs index 16028ea8ec6a5..7966ebbc2ef79 100644 --- a/sdk/provisioning/Azure.Provisioning/src/storage/StorageAccount.cs +++ b/sdk/provisioning/Azure.Provisioning/src/storage/StorageAccount.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.Text; using Azure.Core; using Azure.Provisioning.ResourceManager; using Azure.ResourceManager.Storage; @@ -16,6 +15,7 @@ namespace Azure.Provisioning.Storage public class StorageAccount : Resource { private const string ResourceTypeName = "Microsoft.Storage/storageAccounts"; + private static readonly Func Empty = (name) => ArmStorageModelFactory.StorageAccountData(); /// /// Initializes a new instance of the . @@ -26,7 +26,7 @@ public class StorageAccount : Resource /// The parent. /// The name. public StorageAccount(IConstruct scope, StorageKind kind, StorageSkuName sku, ResourceGroup? parent = null, string name = "sa") - : base(scope, parent, name, ResourceTypeName, "2022-09-01", (name) => ArmStorageModelFactory.StorageAccountData( + : this(scope, kind, sku, parent, name, false, (name) => ArmStorageModelFactory.StorageAccountData( name: name, resourceType: ResourceTypeName, location: Environment.GetEnvironmentVariable("AZURE_LOCATION") ?? AzureLocation.WestUS, @@ -38,6 +38,21 @@ public StorageAccount(IConstruct scope, StorageKind kind, StorageSkuName sku, Re AssignProperty(data => data.Name, GetAzureName(scope, name)); } + private StorageAccount(IConstruct scope, StorageKind kind = default, StorageSkuName sku = default, ResourceGroup? parent = null, string name = "sa", bool isExisting = true, Func? creator = null) + : base(scope, parent, name, ResourceTypeName, "2022-09-01", 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 StorageAccount FromExisting(IConstruct scope, string name, ResourceGroup? parent = null) + => new StorageAccount(scope, parent: parent, name: name, isExisting: true); + /// protected override Resource? FindParentInScope(IConstruct scope) { diff --git a/sdk/provisioning/Azure.Provisioning/src/websites/AppServicePlan.cs b/sdk/provisioning/Azure.Provisioning/src/websites/AppServicePlan.cs index bc70f642958b4..1045c0374e60e 100644 --- a/sdk/provisioning/Azure.Provisioning/src/websites/AppServicePlan.cs +++ b/sdk/provisioning/Azure.Provisioning/src/websites/AppServicePlan.cs @@ -15,17 +15,18 @@ namespace Azure.Provisioning.AppService public class AppServicePlan : Resource { private const string ResourceTypeName = "Microsoft.Web/serverfarms"; + private static readonly Func Empty = (name) => ArmAppServiceModelFactory.AppServicePlanData(); /// /// Initializes a new instance of the . /// /// The scope. - /// The resource name. + /// The resource name. /// The version. /// The location. /// The resource group. - public AppServicePlan(IConstruct scope, string resourceName, string version = "2021-02-01", AzureLocation? location = default, ResourceGroup? parent = default) - : base(scope, parent, resourceName, ResourceTypeName, version, (name) => ArmAppServiceModelFactory.AppServicePlanData( + public AppServicePlan(IConstruct scope, string name, string version = "2021-02-01", AzureLocation? location = default, ResourceGroup? parent = default) + : this(scope, name, version, location, parent, false, (name) => ArmAppServiceModelFactory.AppServicePlanData( name: name, location: location ?? Environment.GetEnvironmentVariable("AZURE_LOCATION") ?? AzureLocation.WestUS, sku: new AppServiceSkuDescription() { Name = "B1" }, @@ -33,6 +34,21 @@ public AppServicePlan(IConstruct scope, string resourceName, string version = "2 { } + private AppServicePlan(IConstruct scope, string name, string version = "2021-02-01", AzureLocation? location = default, ResourceGroup? parent = 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 AppServicePlan FromExisting(IConstruct scope, string name, ResourceGroup? parent = null) + => new AppServicePlan(scope, parent: parent, name: name, isExisting: true); + /// protected override Resource? FindParentInScope(IConstruct scope) { diff --git a/sdk/provisioning/Azure.Provisioning/src/websites/WebSite.cs b/sdk/provisioning/Azure.Provisioning/src/websites/WebSite.cs index 57a753998e886..bb1b3c2854197 100644 --- a/sdk/provisioning/Azure.Provisioning/src/websites/WebSite.cs +++ b/sdk/provisioning/Azure.Provisioning/src/websites/WebSite.cs @@ -32,6 +32,7 @@ public enum WebSiteRuntime public class WebSite : Resource { private const string ResourceTypeName = "Microsoft.Web/sites"; + private static readonly Func Empty = (name) => ArmAppServiceModelFactory.WebSiteData(); private ApplicationSettingsResource AppSettings { get; } @@ -39,20 +40,20 @@ public class WebSite : Resource /// Initializes a new instance of the . /// /// The scope. - /// The resource name. + /// The resource name. /// The appServicePlan. /// The runtime. /// The runtime version /// The version. /// The location. /// The resource group. - public WebSite(IConstruct scope, string resourceName, AppServicePlan appServicePlan, WebSiteRuntime runtime, string runtimeVersion, string version = "2021-02-01", AzureLocation? location = default, ResourceGroup? parent = null) - : base(scope, parent, resourceName, ResourceTypeName, version, (name) => ArmAppServiceModelFactory.WebSiteData( + public WebSite(IConstruct scope, string name, AppServicePlan appServicePlan, WebSiteRuntime runtime, string runtimeVersion, string version = "2021-02-01", AzureLocation? location = default, ResourceGroup? parent = null) + : this(scope, name, appServicePlan, runtime, runtimeVersion, version, location, parent, false, (name) => ArmAppServiceModelFactory.WebSiteData( name: name, location: location ?? Environment.GetEnvironmentVariable("AZURE_LOCATION") ?? AzureLocation.WestUS, resourceType: ResourceTypeName, kind: "app,linux", - appServicePlanId: appServicePlan.Id, + appServicePlanId: appServicePlan?.Id, siteConfig: ArmAppServiceModelFactory.SiteConfigProperties( linuxFxVersion: $"{runtime.ToString().ToLower()}|{runtimeVersion}", isAlwaysOn: true, @@ -69,17 +70,32 @@ public WebSite(IConstruct scope, string resourceName, AppServicePlan appServiceP }), isHttpsOnly: true, identity: new ManagedServiceIdentity(ManagedServiceIdentityType.SystemAssigned))) + { + } + + private WebSite(IConstruct scope, string name, AppServicePlan? appServicePlan = default, WebSiteRuntime runtime = default, string? runtimeVersion = default, string version = "2021-02-01", AzureLocation? location = default, ResourceGroup? parent = null, bool isExisting = false, Func? creator = null) + : base(scope, parent, name, ResourceTypeName, version, creator ?? Empty, isExisting) { var appSettings = runtime == WebSiteRuntime.Dotnetcore - ? new Dictionary() - { + ? new Dictionary() + { { "SCM_DO_BUILD_DURING_DEPLOYMENT", "False"}, { "ENABLE_ORYX_BUILD", "True"} - } - : new Dictionary(); + } + : new Dictionary(); AppSettings = new ApplicationSettingsResource(Scope, appSettings, this); } + /// + /// Creates a new instance of the class referencing an existing instance. + /// + /// The scope. + /// The resource name. + /// The resource group. + /// The KeyVault instance. + public static WebSite FromExisting(IConstruct scope, string name, ResourceGroup? parent = null) + => new WebSite(scope, parent: parent, name: name, isExisting: true); + /// /// Adds an application setting to the web site. /// diff --git a/sdk/provisioning/Azure.Provisioning/src/websites/WebSiteConfigLogs.cs b/sdk/provisioning/Azure.Provisioning/src/websites/WebSiteConfigLogs.cs index 61823e52d6610..48d9a509a8fea 100644 --- a/sdk/provisioning/Azure.Provisioning/src/websites/WebSiteConfigLogs.cs +++ b/sdk/provisioning/Azure.Provisioning/src/websites/WebSiteConfigLogs.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using System; using Azure.Core; using Azure.ResourceManager.AppService; using Azure.ResourceManager.AppService.Models; @@ -13,17 +14,18 @@ namespace Azure.Provisioning.AppService public class WebSiteConfigLogs : Resource { private const string ResourceTypeName = "Microsoft.Web/sites/config"; + private static readonly Func Empty = (name) => ArmAppServiceModelFactory.SiteLogsConfigData(); /// /// Initializes a new instance of the . /// /// The scope. - /// The resource name. + /// The resource name. /// The parent. /// The version. /// The location. - public WebSiteConfigLogs(IConstruct scope, string resourceName, WebSite? parent = null, string version = "2021-02-01", AzureLocation? location = default) - : base(scope, parent, resourceName, ResourceTypeName, version, (name) => ArmAppServiceModelFactory.SiteLogsConfigData( + public WebSiteConfigLogs(IConstruct scope, string name, WebSite? parent = null, string version = "2021-02-01", AzureLocation? location = default) + : this(scope, name, parent, version, location, false, (name) => ArmAppServiceModelFactory.SiteLogsConfigData( name: name, applicationLogs: new ApplicationLogsConfig() { @@ -43,6 +45,21 @@ public WebSiteConfigLogs(IConstruct scope, string resourceName, WebSite? parent { } + private WebSiteConfigLogs(IConstruct scope, string name, WebSite? parent = null, string version = "2021-02-01", 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 WebSiteConfigLogs FromExisting(IConstruct scope, string name, WebSite? parent = null) + => new WebSiteConfigLogs(scope, parent: parent, name: name, isExisting: true); + /// protected override string GetAzureName(IConstruct scope, string resourceName) => resourceName; } diff --git a/sdk/provisioning/Azure.Provisioning/src/websites/WebSitePublishingCredentialPolicy.cs b/sdk/provisioning/Azure.Provisioning/src/websites/WebSitePublishingCredentialPolicy.cs index 385a4f9551560..0b6ac766edf6b 100644 --- a/sdk/provisioning/Azure.Provisioning/src/websites/WebSitePublishingCredentialPolicy.cs +++ b/sdk/provisioning/Azure.Provisioning/src/websites/WebSitePublishingCredentialPolicy.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using System; using Azure.Core; using Azure.ResourceManager.AppService; using Azure.ResourceManager.AppService.Models; @@ -13,19 +14,36 @@ namespace Azure.Provisioning.AppService public class WebSitePublishingCredentialPolicy : Resource { private const string ResourceTypeName = "Microsoft.Web/sites/basicPublishingCredentialsPolicies"; + private static readonly Func Empty = (name) => ArmAppServiceModelFactory.CsmPublishingCredentialsPoliciesEntityData(); /// /// Initializes a new instance of the class. /// /// The scope. - /// The resource name. + /// The resource name. + /// The parent. /// The version. /// The location. - public WebSitePublishingCredentialPolicy(IConstruct scope, string resourceName, string version = "2021-02-01", AzureLocation? location = default) - : base(scope, null, resourceName, ResourceTypeName, version, (name) => ArmAppServiceModelFactory.CsmPublishingCredentialsPoliciesEntityData( + public WebSitePublishingCredentialPolicy(IConstruct scope, string name, WebSite? parent = null, string version = "2021-02-01", AzureLocation? location = default) + : this(scope, name, parent, version, location, false, (name) => ArmAppServiceModelFactory.CsmPublishingCredentialsPoliciesEntityData( name: name, allow: false)) { } + + private WebSitePublishingCredentialPolicy(IConstruct scope, string name, WebSite? parent = null, string version = "2021-02-01", 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 WebSitePublishingCredentialPolicy FromExisting(IConstruct scope, string name, WebSite? parent = null) + => new WebSitePublishingCredentialPolicy(scope, parent: parent, name: name, isExisting: true); } } diff --git a/sdk/provisioning/Azure.Provisioning/tests/Infrastructure/ExistingResources/main.bicep b/sdk/provisioning/Azure.Provisioning/tests/Infrastructure/ExistingResources/main.bicep new file mode 100644 index 0000000000000..136bc70205674 --- /dev/null +++ b/sdk/provisioning/Azure.Provisioning/tests/Infrastructure/ExistingResources/main.bicep @@ -0,0 +1,15 @@ +targetScope = 'subscription' + + +resource resourceGroup_I6QNkoPsb 'Microsoft.Resources/resourceGroups@2023-07-01' = { + name: 'rg-TEST' + location: 'westus' + tags: { + 'azd-env-name': 'TEST' + } +} + +module rg_TEST_module './resources/rg_TEST_module/rg_TEST_module.bicep' = { + name: 'rg_TEST_module' + scope: resourceGroup_I6QNkoPsb +} 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 new file mode 100644 index 0000000000000..8458fb84f1f1d --- /dev/null +++ b/sdk/provisioning/Azure.Provisioning/tests/Infrastructure/ExistingResources/resources/rg_TEST_module/rg_TEST_module.bicep @@ -0,0 +1,65 @@ + +resource appConfigurationStore_OcIExgz1d 'Microsoft.AppConfiguration/configurationStores@2023-03-01' existing = { + name: 'existingAppConfig' +} + +resource keyVault_78IwnSu6G 'Microsoft.KeyVault/vaults@2023-02-01' existing = { + name: 'existingVault' +} + +resource keyVaultSecret_ChWKOL5pG 'Microsoft.KeyVault/vaults/secrets@2023-02-01' existing = { + name: 'existingSecret' +} + +resource storageAccount_LhqOcwcwC 'Microsoft.Storage/storageAccounts@2022-09-01' existing = { + name: 'existingStorage' +} + +resource blobService_KtyZZZEH1 'Microsoft.Storage/storageAccounts/blobServices@2022-09-01' existing = { + name: 'existingBlobService' +} + +resource webSite_C2Aq73IJb 'Microsoft.Web/sites@2021-02-01' existing = { + name: 'existingWebSite' +} + +resource webSiteConfigLogs_7A7a8DHfx 'Microsoft.Web/sites/config@2021-02-01' existing = { + name: 'existingWebSiteConfigLogs' +} + +resource webSitePublishingCredentialPolicy_thziHKVBm 'Microsoft.Web/sites/basicPublishingCredentialsPolicies@2021-02-01' existing = { + name: 'existingWebSitePublishingCredentialPolicy' +} + +resource postgreSqlFlexibleServer_0TaJ8imA6 'Microsoft.DBforPostgreSQL/flexibleServers@2020-06-01' existing = { + name: 'existingPostgreSql' +} + +resource sqlServer_O1efuGmrm 'Microsoft.Sql/servers@2022-08-01-preview' existing = { + name: 'existingSqlServer' +} + +resource sqlDatabase_m9ZmzLlHS 'Microsoft.Sql/servers/databases@2022-08-01-preview' existing = { + name: 'existingSqlDatabase' +} + +resource sqlFirewallRule_SFMW2DxVf 'Microsoft.Sql/servers/firewallRules@2020-11-01-preview' existing = { + name: 'existingSqlFirewallRule' +} + +resource redisCache_nxA8uMVGD 'Microsoft.Cache/Redis@2020-06-01' existing = { + name: 'existingRedis' +} + +resource deploymentScript_QqrJz7yzH 'Microsoft.Resources/deploymentScripts@2020-10-01' existing = { + name: 'existingDeploymentScript' +} + +resource appServicePlan_D5p3EVvRT 'Microsoft.Web/serverfarms@2021-02-01' existing = { + name: 'existingAppServicePlan' +} + +resource applicationSettingsResource_6DtpuGITF 'Microsoft.Web/sites/config@2021-02-01' = { + parent: webSite_C2Aq73IJb + name: 'appsettings' +} diff --git a/sdk/provisioning/Azure.Provisioning/tests/Infrastructure/RedisCacheWithExistingKeyVault/main.bicep b/sdk/provisioning/Azure.Provisioning/tests/Infrastructure/RedisCacheWithExistingKeyVault/main.bicep index 313c70f69c6d4..66e545e2fa163 100644 --- a/sdk/provisioning/Azure.Provisioning/tests/Infrastructure/RedisCacheWithExistingKeyVault/main.bicep +++ b/sdk/provisioning/Azure.Provisioning/tests/Infrastructure/RedisCacheWithExistingKeyVault/main.bicep @@ -4,7 +4,7 @@ targetScope = 'resourceGroup' param location string = resourceGroup().location -resource keyVault_gudpA4XUx 'Microsoft.KeyVault/vaults@2023-02-01' existing = { +resource keyVault_vxw9QYjTK 'Microsoft.KeyVault/vaults@2023-02-01' existing = { name: 'existingVault' } @@ -22,8 +22,8 @@ resource redisCache_YE3v6ym48 'Microsoft.Cache/Redis@2020-06-01' = { } } -resource keyVaultSecret_BjriHg4Dh 'Microsoft.KeyVault/vaults/secrets@2023-02-01' = { - parent: keyVault_gudpA4XUx +resource keyVaultSecret_PGXfP6Z9q 'Microsoft.KeyVault/vaults/secrets@2023-02-01' = { + parent: keyVault_vxw9QYjTK name: 'primaryConnectionString' location: location properties: { @@ -31,8 +31,8 @@ resource keyVaultSecret_BjriHg4Dh 'Microsoft.KeyVault/vaults/secrets@2023-02-01' } } -resource keyVaultSecret_pekkgeXRu 'Microsoft.KeyVault/vaults/secrets@2023-02-01' = { - parent: keyVault_gudpA4XUx +resource keyVaultSecret_bTFii2gaH 'Microsoft.KeyVault/vaults/secrets@2023-02-01' = { + parent: keyVault_vxw9QYjTK name: 'secondaryConnectionStrin' location: location properties: { @@ -40,4 +40,4 @@ resource keyVaultSecret_pekkgeXRu 'Microsoft.KeyVault/vaults/secrets@2023-02-01' } } -output vaultUri string = keyVault_gudpA4XUx.properties.vaultUri +output vaultUri string = keyVault_vxw9QYjTK.properties.vaultUri diff --git a/sdk/provisioning/Azure.Provisioning/tests/ProvisioningTests.cs b/sdk/provisioning/Azure.Provisioning/tests/ProvisioningTests.cs index 4f3e5a9e460e5..d9d1efa7113d5 100644 --- a/sdk/provisioning/Azure.Provisioning/tests/ProvisioningTests.cs +++ b/sdk/provisioning/Azure.Provisioning/tests/ProvisioningTests.cs @@ -240,7 +240,7 @@ public async Task RedisCacheWithExistingKeyVault() { TestInfrastructure infrastructure = new TestInfrastructure(configuration: new Configuration { UseInteractiveMode = true }); var cache = new RedisCache(infrastructure); - var kv = KeyVault.FromExisting(infrastructure, name: "existingVault"); + var kv = KeyVault.FromExisting(infrastructure, name: "'existingVault'"); kv.AddOutput(data => data.Properties.VaultUri, "vaultUri"); // can't mutate existing resource @@ -578,6 +578,35 @@ public async Task OutputsSpanningModules() await ValidateBicepAsync(); } + [RecordedTest] + public void ExistingResources() + { + var infra = new TestInfrastructure(); + var rg = infra.AddResourceGroup(); + infra.AddResource(AppConfigurationStore.FromExisting(infra, "'existingAppConfig'", rg)); + var kv = KeyVault.FromExisting(infra, "'existingVault'", rg); + infra.AddResource(kv); + var sa = StorageAccount.FromExisting(infra, "'existingStorage'", rg); + infra.AddResource(sa); + var web = WebSite.FromExisting(infra, "'existingWebSite'", rg); + infra.AddResource(web); + infra.AddResource(KeyVaultSecret.FromExisting(infra, "'existingSecret'", kv)); + infra.AddResource(PostgreSqlFlexibleServer.FromExisting(infra, "'existingPostgreSql'", rg)); + var sql = SqlServer.FromExisting(infra, "'existingSqlServer'", rg); + infra.AddResource(sql); + infra.AddResource(Redis.RedisCache.FromExisting(infra, "'existingRedis'", rg)); + infra.AddResource(DeploymentScript.FromExisting(infra, "'existingDeploymentScript'", rg)); + infra.AddResource(SqlDatabase.FromExisting(infra, "'existingSqlDatabase'", sql)); + infra.AddResource(SqlFirewallRule.FromExisting(infra, "'existingSqlFirewallRule'", sql)); + infra.AddResource(BlobService.FromExisting(infra, "'existingBlobService'", sa)); + infra.AddResource(AppServicePlan.FromExisting(infra, "'existingAppServicePlan'", rg)); + infra.AddResource(WebSiteConfigLogs.FromExisting(infra, "'existingWebSiteConfigLogs'", web)); + infra.AddResource(WebSitePublishingCredentialPolicy.FromExisting(infra, "'existingWebSitePublishingCredentialPolicy'", web)); + infra.Build(GetOutputPath()); + //these resources can't be verified since they won't exist. + //await ValidateBicepAsync(); + } + public async Task ValidateBicepAsync(BinaryData? parameters = null, bool interactiveMode = false) { if (CoreTestEnvironment.GlobalIsRunningInCI)