From 241e17bee68068518e59aa0e823499e83821e1e4 Mon Sep 17 00:00:00 2001 From: jolov Date: Thu, 7 Mar 2024 09:27:22 -0800 Subject: [PATCH 1/5] postgres fixes --- .../api/Azure.Provisioning.net6.0.cs | 16 ++++- .../api/Azure.Provisioning.netstandard2.0.cs | 16 ++++- .../src/postgresql/PostgreSqlFirewallRule.cs | 63 ++++++++++++++++++ .../postgresql/PostgreSqlFlexibleServer.cs | 2 +- .../PostgreSqlFlexibleServerDatabase.cs | 65 +++++++++++++++++++ .../src/sqlmanagement/SqlDatabase.cs | 6 +- .../src/sqlmanagement/SqlServer.cs | 23 ++++--- .../Infrastructure/PostgreSql/main.bicep | 18 ++++- .../main.bicep | 32 +++++++++ .../tests/ProvisioningTests.cs | 29 +++++++-- 10 files changed, 247 insertions(+), 23 deletions(-) create mode 100644 sdk/provisioning/Azure.Provisioning/src/postgresql/PostgreSqlFirewallRule.cs create mode 100644 sdk/provisioning/Azure.Provisioning/src/postgresql/PostgreSqlFlexibleServerDatabase.cs create mode 100644 sdk/provisioning/Azure.Provisioning/tests/Infrastructure/SqlServerDatabaseWithAutoAddedParent/main.bicep 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 c73767f249eea..f43170aebfb01 100644 --- a/sdk/provisioning/Azure.Provisioning/api/Azure.Provisioning.net6.0.cs +++ b/sdk/provisioning/Azure.Provisioning/api/Azure.Provisioning.net6.0.cs @@ -276,13 +276,25 @@ public partial class PostgreSqlConnectionString : Azure.Provisioning.ConnectionS { internal PostgreSqlConnectionString() : base (default(string)) { } } + public partial class PostgreSqlFirewallRule : Azure.Provisioning.Resource + { + public PostgreSqlFirewallRule(Azure.Provisioning.IConstruct scope, string? startIpAddress = null, string? endIpAddress = null, Azure.Provisioning.PostgreSql.PostgreSqlFlexibleServer? parent = null, string name = "fw", string version = "2023-03-01-preview") : 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.PostgreSql.PostgreSqlFirewallRule FromExisting(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.PostgreSql.PostgreSqlFlexibleServer parent) { throw null; } + } public partial class PostgreSqlFlexibleServer : Azure.Provisioning.Resource { - public PostgreSqlFlexibleServer(Azure.Provisioning.IConstruct scope, Azure.Provisioning.Parameter administratorLogin, Azure.Provisioning.Parameter administratorPassword, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerSku? sku = null, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerVersion? serverVersion = default(Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerVersion?), Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerHighAvailability? highAvailability = null, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerStorage? storage = null, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerDataEncryption? encryption = null, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerBackupProperties? backup = null, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerNetwork? network = null, string? availabilityZone = null, Azure.Provisioning.ResourceManager.ResourceGroup? parent = null, string name = "postgres", string version = "2020-06-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 PostgreSqlFlexibleServer(Azure.Provisioning.IConstruct scope, Azure.Provisioning.Parameter administratorLogin, Azure.Provisioning.Parameter administratorPassword, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerSku? sku = null, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerVersion? serverVersion = default(Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerVersion?), Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerHighAvailability? highAvailability = null, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerStorage? storage = null, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerDataEncryption? encryption = null, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerBackupProperties? backup = null, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerNetwork? network = null, string? availabilityZone = null, Azure.Provisioning.ResourceManager.ResourceGroup? parent = null, string name = "postgres", string version = "2021-06-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.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; } } + public partial class PostgreSqlFlexibleServerDatabase : Azure.Provisioning.Resource + { + public PostgreSqlFlexibleServerDatabase(Azure.Provisioning.IConstruct scope, Azure.Provisioning.PostgreSql.PostgreSqlFlexibleServer? parent = null, string name = "postgres", string version = "2021-06-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.PostgreSql.PostgreSqlFlexibleServerDatabase FromExisting(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.PostgreSql.PostgreSqlFlexibleServer? parent) { throw null; } + } } namespace Azure.Provisioning.Redis { @@ -354,7 +366,7 @@ public partial class SqlFirewallRule : Azure.Provisioning.Resource { - 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)) { } + public SqlServer(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.Parameter? administratorLogin = default(Azure.Provisioning.Parameter?), Azure.Provisioning.Parameter? administratorPassword = default(Azure.Provisioning.Parameter?), Azure.Provisioning.Sql.SqlServerAdministrator? administrator = default(Azure.Provisioning.Sql.SqlServerAdministrator?), Azure.Provisioning.ResourceManager.ResourceGroup? parent = null, 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 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; } } 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 c73767f249eea..f43170aebfb01 100644 --- a/sdk/provisioning/Azure.Provisioning/api/Azure.Provisioning.netstandard2.0.cs +++ b/sdk/provisioning/Azure.Provisioning/api/Azure.Provisioning.netstandard2.0.cs @@ -276,13 +276,25 @@ public partial class PostgreSqlConnectionString : Azure.Provisioning.ConnectionS { internal PostgreSqlConnectionString() : base (default(string)) { } } + public partial class PostgreSqlFirewallRule : Azure.Provisioning.Resource + { + public PostgreSqlFirewallRule(Azure.Provisioning.IConstruct scope, string? startIpAddress = null, string? endIpAddress = null, Azure.Provisioning.PostgreSql.PostgreSqlFlexibleServer? parent = null, string name = "fw", string version = "2023-03-01-preview") : 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.PostgreSql.PostgreSqlFirewallRule FromExisting(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.PostgreSql.PostgreSqlFlexibleServer parent) { throw null; } + } public partial class PostgreSqlFlexibleServer : Azure.Provisioning.Resource { - public PostgreSqlFlexibleServer(Azure.Provisioning.IConstruct scope, Azure.Provisioning.Parameter administratorLogin, Azure.Provisioning.Parameter administratorPassword, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerSku? sku = null, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerVersion? serverVersion = default(Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerVersion?), Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerHighAvailability? highAvailability = null, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerStorage? storage = null, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerDataEncryption? encryption = null, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerBackupProperties? backup = null, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerNetwork? network = null, string? availabilityZone = null, Azure.Provisioning.ResourceManager.ResourceGroup? parent = null, string name = "postgres", string version = "2020-06-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 PostgreSqlFlexibleServer(Azure.Provisioning.IConstruct scope, Azure.Provisioning.Parameter administratorLogin, Azure.Provisioning.Parameter administratorPassword, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerSku? sku = null, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerVersion? serverVersion = default(Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerVersion?), Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerHighAvailability? highAvailability = null, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerStorage? storage = null, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerDataEncryption? encryption = null, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerBackupProperties? backup = null, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerNetwork? network = null, string? availabilityZone = null, Azure.Provisioning.ResourceManager.ResourceGroup? parent = null, string name = "postgres", string version = "2021-06-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.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; } } + public partial class PostgreSqlFlexibleServerDatabase : Azure.Provisioning.Resource + { + public PostgreSqlFlexibleServerDatabase(Azure.Provisioning.IConstruct scope, Azure.Provisioning.PostgreSql.PostgreSqlFlexibleServer? parent = null, string name = "postgres", string version = "2021-06-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.PostgreSql.PostgreSqlFlexibleServerDatabase FromExisting(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.PostgreSql.PostgreSqlFlexibleServer? parent) { throw null; } + } } namespace Azure.Provisioning.Redis { @@ -354,7 +366,7 @@ public partial class SqlFirewallRule : Azure.Provisioning.Resource { - 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)) { } + public SqlServer(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.Parameter? administratorLogin = default(Azure.Provisioning.Parameter?), Azure.Provisioning.Parameter? administratorPassword = default(Azure.Provisioning.Parameter?), Azure.Provisioning.Sql.SqlServerAdministrator? administrator = default(Azure.Provisioning.Sql.SqlServerAdministrator?), Azure.Provisioning.ResourceManager.ResourceGroup? parent = null, 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 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; } } diff --git a/sdk/provisioning/Azure.Provisioning/src/postgresql/PostgreSqlFirewallRule.cs b/sdk/provisioning/Azure.Provisioning/src/postgresql/PostgreSqlFirewallRule.cs new file mode 100644 index 0000000000000..5952fdcb3f41f --- /dev/null +++ b/sdk/provisioning/Azure.Provisioning/src/postgresql/PostgreSqlFirewallRule.cs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Net; +using Azure.ResourceManager.PostgreSql; +using Azure.ResourceManager.PostgreSql.Models; +using Azure.ResourceManager.Sql; +using Azure.ResourceManager.Sql.Models; + +namespace Azure.Provisioning.PostgreSql +{ + /// + /// Represents a SQL firewall rule. + /// + public class PostgreSqlFirewallRule : Resource + { + private const string ResourceTypeName = "Microsoft.DBforPostgreSQL/flexibleServers/firewallRules"; + private static readonly Func Empty = (name) => ArmPostgreSqlModelFactory.PostgreSqlFirewallRuleData(); + + /// + /// Initializes a new instance of the . + /// + /// The scope. + /// The start IP address. + /// The end IP address. + /// The parent. + /// The name. + /// The version. + public PostgreSqlFirewallRule(IConstruct scope, string? startIpAddress = default, string? endIpAddress = default, PostgreSqlFlexibleServer? parent = default, string name = "fw", string version = "2023-03-01-preview") + : this(scope, parent, name, version, false, (name) => ArmPostgreSqlModelFactory.PostgreSqlFirewallRuleData( + name: name, + resourceType: ResourceTypeName, + startIPAddress: startIpAddress != null ? IPAddress.Parse(startIpAddress) : IPAddress.Parse("0.0.0.1"), + endIPAddress: endIpAddress != null ? IPAddress.Parse(endIpAddress) : IPAddress.Parse("255.255.255.254"))) + { + } + + private PostgreSqlFirewallRule(IConstruct scope, PostgreSqlFlexibleServer? parent = default, string name = "fw", string version = "2023-03-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 PostgreSqlFirewallRule FromExisting(IConstruct scope, string name, PostgreSqlFlexibleServer parent) + => new PostgreSqlFirewallRule(scope, parent: parent, name: name, isExisting: true); + + /// + protected override Resource? FindParentInScope(IConstruct scope) + { + return scope.GetSingleResource() ?? new PostgreSqlFlexibleServer( + scope, + new Parameter("administratorLogin"), + new Parameter("administratorPassword", isSecure: true)); + } + } +} diff --git a/sdk/provisioning/Azure.Provisioning/src/postgresql/PostgreSqlFlexibleServer.cs b/sdk/provisioning/Azure.Provisioning/src/postgresql/PostgreSqlFlexibleServer.cs index 4f79b96a8c66d..caeac06102b6f 100644 --- a/sdk/provisioning/Azure.Provisioning/src/postgresql/PostgreSqlFlexibleServer.cs +++ b/sdk/provisioning/Azure.Provisioning/src/postgresql/PostgreSqlFlexibleServer.cs @@ -50,7 +50,7 @@ public PostgreSqlFlexibleServer( string? availabilityZone = default, ResourceGroup? parent = default, string name = "postgres", - string version = "2020-06-01", + string version = "2021-06-01", AzureLocation? location = default) : this(scope, parent, name, version, false, (name) => ArmPostgreSqlFlexibleServersModelFactory.PostgreSqlFlexibleServerData( name: name, diff --git a/sdk/provisioning/Azure.Provisioning/src/postgresql/PostgreSqlFlexibleServerDatabase.cs b/sdk/provisioning/Azure.Provisioning/src/postgresql/PostgreSqlFlexibleServerDatabase.cs new file mode 100644 index 0000000000000..ca20aae684dc7 --- /dev/null +++ b/sdk/provisioning/Azure.Provisioning/src/postgresql/PostgreSqlFlexibleServerDatabase.cs @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Azure.ResourceManager.PostgreSql.FlexibleServers; +using Azure.ResourceManager.PostgreSql.FlexibleServers.Models; + +namespace Azure.Provisioning.PostgreSql +{ + /// + /// Represents a PostGreSql flexible database. + /// + public class PostgreSqlFlexibleServerDatabase : Resource + { + private const string ResourceTypeName = "Microsoft.DBforPostgreSQL/flexibleServers/databases"; + private static readonly Func Empty = (name) + => ArmPostgreSqlFlexibleServersModelFactory.PostgreSqlFlexibleServerDatabaseData(); + + /// + /// Creates a new instance of the class. + /// + /// The scope. + /// The parent. + /// The name. + /// The version. + public PostgreSqlFlexibleServerDatabase( + IConstruct scope, + PostgreSqlFlexibleServer? parent = null, + string name = "postgres", + string version = "2021-06-01") + : this(scope, parent, name, version, false, (name) => ArmPostgreSqlFlexibleServersModelFactory.PostgreSqlFlexibleServerDatabaseData(name: name)) + { + } + + private PostgreSqlFlexibleServerDatabase( + IConstruct scope, + PostgreSqlFlexibleServer? parent = default, + string name = "postgres", + string version = "2020-06-01", + 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 PostgreSqlFlexibleServerDatabase FromExisting(IConstruct scope, string name, PostgreSqlFlexibleServer? parent) + => new PostgreSqlFlexibleServerDatabase(scope, parent: parent, name: name, isExisting: true); + + /// + protected override Resource? FindParentInScope(IConstruct scope) + { + return scope.GetSingleResource() ?? new PostgreSqlFlexibleServer( + scope, + new Parameter("administratorLogin"), + new Parameter("administratorPassword", isSecure: true)); + } + } +} diff --git a/sdk/provisioning/Azure.Provisioning/src/sqlmanagement/SqlDatabase.cs b/sdk/provisioning/Azure.Provisioning/src/sqlmanagement/SqlDatabase.cs index 0f22d60433ec8..8a1ab886ee842 100644 --- a/sdk/provisioning/Azure.Provisioning/src/sqlmanagement/SqlDatabase.cs +++ b/sdk/provisioning/Azure.Provisioning/src/sqlmanagement/SqlDatabase.cs @@ -59,7 +59,11 @@ public static SqlDatabase FromExisting(IConstruct scope, string name, SqlServer /// protected override Resource? FindParentInScope(IConstruct scope) { - return scope.GetSingleResource() ?? new SqlServer(scope, "sql"); + return scope.GetSingleResource() ?? new SqlServer( + scope, + "sql", + new Parameter("administratorLogin"), + new Parameter("administratorPassword", isSecure: true)); } } } diff --git a/sdk/provisioning/Azure.Provisioning/src/sqlmanagement/SqlServer.cs b/sdk/provisioning/Azure.Provisioning/src/sqlmanagement/SqlServer.cs index 09d8377b55034..f83a65fe501f7 100644 --- a/sdk/provisioning/Azure.Provisioning/src/sqlmanagement/SqlServer.cs +++ b/sdk/provisioning/Azure.Provisioning/src/sqlmanagement/SqlServer.cs @@ -22,19 +22,18 @@ public class SqlServer : Resource /// /// The scope. /// The name. - /// The parent. - /// The administrator login. - /// The administrator password. + /// The administrator login. + /// The administrator password. /// The administrator when using Entra. + /// The parent. /// The version. /// The location. - public SqlServer( - IConstruct scope, + public SqlServer(IConstruct scope, string name, - ResourceGroup? parent = null, - Parameter? adminLogin = default, - Parameter? adminPassword = default, + Parameter? administratorLogin = default, + Parameter? administratorPassword = default, SqlServerAdministrator? administrator = default, + ResourceGroup? parent = null, string version = "2022-08-01-preview", AzureLocation? location = default) : this(scope, name, parent, version, false, (name) => ArmSqlModelFactory.SqlServerData( @@ -47,13 +46,13 @@ public SqlServer( administrators: new ServerExternalAdministrator())) { AssignProperty(data => data.Name, GetAzureName(scope, name)); - if (adminLogin != null) + if (administratorLogin != null) { - AssignProperty(data => data.AdministratorLogin, adminLogin.Value); + AssignProperty(data => data.AdministratorLogin, administratorLogin.Value); } - if (adminPassword != null) + if (administratorPassword != null) { - AssignProperty(data => data.AdministratorLoginPassword, adminPassword.Value); + AssignProperty(data => data.AdministratorLoginPassword, administratorPassword.Value); } if (administrator != null) { diff --git a/sdk/provisioning/Azure.Provisioning/tests/Infrastructure/PostgreSql/main.bicep b/sdk/provisioning/Azure.Provisioning/tests/Infrastructure/PostgreSql/main.bicep index a1b6598920ae4..afa53b164f66a 100644 --- a/sdk/provisioning/Azure.Provisioning/tests/Infrastructure/PostgreSql/main.bicep +++ b/sdk/provisioning/Azure.Provisioning/tests/Infrastructure/PostgreSql/main.bicep @@ -20,7 +20,7 @@ param serverEdition string param p string = 'name' -resource postgreSqlFlexibleServer_mZ8PC2Gce 'Microsoft.DBforPostgreSQL/flexibleServers@2020-06-01' = { +resource postgreSqlFlexibleServer_mZ8PC2Gce 'Microsoft.DBforPostgreSQL/flexibleServers@2021-06-01' = { name: toLower(take(concat('postgres', uniqueString(resourceGroup().id)), 24)) location: location sku: { @@ -41,6 +41,22 @@ resource postgreSqlFlexibleServer_mZ8PC2Gce 'Microsoft.DBforPostgreSQL/flexibleS } } +resource postgreSqlFlexibleServerDatabase_ZKSktt9cR 'Microsoft.DBforPostgreSQL/flexibleServers/databases@2021-06-01' = { + parent: postgreSqlFlexibleServer_mZ8PC2Gce + name: 'postgres' + properties: { + } +} + +resource postgreSqlFirewallRule_wheM1oYbH 'Microsoft.DBforPostgreSQL/flexibleServers/firewallRules@2023-03-01-preview' = { + parent: postgreSqlFlexibleServer_mZ8PC2Gce + name: 'fw' + properties: { + startIpAddress: '0.0.0.0' + endIpAddress: '255.255.255.255' + } +} + resource keyVault_5t0GshPLB 'Microsoft.KeyVault/vaults@2023-02-01' = { name: p location: location diff --git a/sdk/provisioning/Azure.Provisioning/tests/Infrastructure/SqlServerDatabaseWithAutoAddedParent/main.bicep b/sdk/provisioning/Azure.Provisioning/tests/Infrastructure/SqlServerDatabaseWithAutoAddedParent/main.bicep new file mode 100644 index 0000000000000..e10236f9fa625 --- /dev/null +++ b/sdk/provisioning/Azure.Provisioning/tests/Infrastructure/SqlServerDatabaseWithAutoAddedParent/main.bicep @@ -0,0 +1,32 @@ +targetScope = 'resourceGroup' + +@description('') +param location string = resourceGroup().location + +@description('') +param administratorLogin string + +@secure() +@description('') +param administratorPassword string + + +resource sqlServer_iWTDw4HGr 'Microsoft.Sql/servers@2022-08-01-preview' = { + name: toLower(take(concat('sql', uniqueString(resourceGroup().id)), 24)) + location: location + properties: { + administratorLogin: administratorLogin + administratorLoginPassword: administratorPassword + version: '12.0' + minimalTlsVersion: '1.2' + publicNetworkAccess: 'Enabled' + } +} + +resource sqlDatabase_WdzeeqGIM 'Microsoft.Sql/servers/databases@2022-08-01-preview' = { + parent: sqlServer_iWTDw4HGr + name: 'db' + location: location + properties: { + } +} diff --git a/sdk/provisioning/Azure.Provisioning/tests/ProvisioningTests.cs b/sdk/provisioning/Azure.Provisioning/tests/ProvisioningTests.cs index 09237b637c8bc..c5fdaeb5b579f 100644 --- a/sdk/provisioning/Azure.Provisioning/tests/ProvisioningTests.cs +++ b/sdk/provisioning/Azure.Provisioning/tests/ProvisioningTests.cs @@ -137,8 +137,8 @@ public async Task SqlServerUsingAdminPassword() var sqlServer = new SqlServer( infrastructure, "sqlserver", - adminLogin: new Parameter("adminLogin", "SQL Server administrator login"), - adminPassword: new Parameter("adminPassword", "SQL Server administrator password", isSecure: true)); + administratorLogin: new Parameter("adminLogin", "SQL Server administrator login"), + administratorPassword: new Parameter("adminPassword", "SQL Server administrator password", isSecure: true)); _ = new SqlDatabase(infrastructure, sqlServer); infrastructure.Build(GetOutputPath()); @@ -191,8 +191,8 @@ public async Task SqlServerUsingHybrid() var sqlServer = new SqlServer( infrastructure, "sqlserver", - adminLogin: new Parameter("adminLogin", "SQL Server administrator login"), - adminPassword: new Parameter("adminPassword", "SQL Server administrator password", isSecure: true), + administratorLogin: new Parameter("adminLogin", "SQL Server administrator login"), + administratorPassword: new Parameter("adminPassword", "SQL Server administrator password", isSecure: true), administrator: admin); _ = new SqlDatabase(infrastructure, sqlServer); @@ -211,6 +211,23 @@ await ValidateBicepAsync( interactiveMode: true); } + [RecordedTest] + public async Task SqlServerDatabaseWithAutoAddedParent() + { + TestInfrastructure infrastructure = new TestInfrastructure(configuration: new Configuration { UseInteractiveMode = true }); + _ = new SqlDatabase(infrastructure); + infrastructure.Build(GetOutputPath()); + + await ValidateBicepAsync( + parameters: BinaryData.FromObjectAsJson( + new + { + administratorLogin = new { value = "admin" }, + administratorPassword = new { value = "password" } + }), + interactiveMode: true); + } + [RecordedTest] public async Task RedisCache() { @@ -280,6 +297,10 @@ public async Task PostgreSql() // verify we can assign a property that is already assigned automatically by the CDK var p = new Parameter("p", defaultValue: "name"); kv.AssignProperty(x=> x.Name, p); + + _ = new PostgreSqlFlexibleServerDatabase(infrastructure, server); + _ = new PostgreSqlFirewallRule(infrastructure, parent: server, startIpAddress: "0.0.0.0", endIpAddress: "255.255.255.255"); + _ = new KeyVaultSecret(infrastructure, "connectionString", server.GetConnectionString(adminLogin, adminPassword)); infrastructure.Build(GetOutputPath()); From 3bda204c93cbef286af0049e617b43d2699e0772 Mon Sep 17 00:00:00 2001 From: jolov Date: Thu, 7 Mar 2024 09:37:29 -0800 Subject: [PATCH 2/5] Don't auto add params --- .../Azure.Provisioning/assets.json | 2 +- .../PostgreSqlFlexibleServerDatabase.cs | 5 +-- .../src/sqlmanagement/SqlDatabase.cs | 6 +--- .../main.bicep | 32 ------------------- .../tests/ProvisioningTests.cs | 21 ++++++------ 5 files changed, 12 insertions(+), 54 deletions(-) delete mode 100644 sdk/provisioning/Azure.Provisioning/tests/Infrastructure/SqlServerDatabaseWithAutoAddedParent/main.bicep diff --git a/sdk/provisioning/Azure.Provisioning/assets.json b/sdk/provisioning/Azure.Provisioning/assets.json index 60fcd698149c2..e93933e11ace8 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_b097187c9f" + "Tag": "net/provisioning/Azure.Provisioning_31fa1a137f" } \ No newline at end of file diff --git a/sdk/provisioning/Azure.Provisioning/src/postgresql/PostgreSqlFlexibleServerDatabase.cs b/sdk/provisioning/Azure.Provisioning/src/postgresql/PostgreSqlFlexibleServerDatabase.cs index ca20aae684dc7..e4476ff9700ad 100644 --- a/sdk/provisioning/Azure.Provisioning/src/postgresql/PostgreSqlFlexibleServerDatabase.cs +++ b/sdk/provisioning/Azure.Provisioning/src/postgresql/PostgreSqlFlexibleServerDatabase.cs @@ -56,10 +56,7 @@ public static PostgreSqlFlexibleServerDatabase FromExisting(IConstruct scope, st /// protected override Resource? FindParentInScope(IConstruct scope) { - return scope.GetSingleResource() ?? new PostgreSqlFlexibleServer( - scope, - new Parameter("administratorLogin"), - new Parameter("administratorPassword", isSecure: true)); + return scope.GetSingleResource() ?? throw new InvalidOperationException("A PostgreSQL server was not found in the construct."); } } } diff --git a/sdk/provisioning/Azure.Provisioning/src/sqlmanagement/SqlDatabase.cs b/sdk/provisioning/Azure.Provisioning/src/sqlmanagement/SqlDatabase.cs index 8a1ab886ee842..45966d402ce0b 100644 --- a/sdk/provisioning/Azure.Provisioning/src/sqlmanagement/SqlDatabase.cs +++ b/sdk/provisioning/Azure.Provisioning/src/sqlmanagement/SqlDatabase.cs @@ -59,11 +59,7 @@ public static SqlDatabase FromExisting(IConstruct scope, string name, SqlServer /// protected override Resource? FindParentInScope(IConstruct scope) { - return scope.GetSingleResource() ?? new SqlServer( - scope, - "sql", - new Parameter("administratorLogin"), - new Parameter("administratorPassword", isSecure: true)); + return scope.GetSingleResource() ?? throw new InvalidOperationException("A SQL server was not found in the construct."); } } } diff --git a/sdk/provisioning/Azure.Provisioning/tests/Infrastructure/SqlServerDatabaseWithAutoAddedParent/main.bicep b/sdk/provisioning/Azure.Provisioning/tests/Infrastructure/SqlServerDatabaseWithAutoAddedParent/main.bicep deleted file mode 100644 index e10236f9fa625..0000000000000 --- a/sdk/provisioning/Azure.Provisioning/tests/Infrastructure/SqlServerDatabaseWithAutoAddedParent/main.bicep +++ /dev/null @@ -1,32 +0,0 @@ -targetScope = 'resourceGroup' - -@description('') -param location string = resourceGroup().location - -@description('') -param administratorLogin string - -@secure() -@description('') -param administratorPassword string - - -resource sqlServer_iWTDw4HGr 'Microsoft.Sql/servers@2022-08-01-preview' = { - name: toLower(take(concat('sql', uniqueString(resourceGroup().id)), 24)) - location: location - properties: { - administratorLogin: administratorLogin - administratorLoginPassword: administratorPassword - version: '12.0' - minimalTlsVersion: '1.2' - publicNetworkAccess: 'Enabled' - } -} - -resource sqlDatabase_WdzeeqGIM 'Microsoft.Sql/servers/databases@2022-08-01-preview' = { - parent: sqlServer_iWTDw4HGr - name: 'db' - location: location - properties: { - } -} diff --git a/sdk/provisioning/Azure.Provisioning/tests/ProvisioningTests.cs b/sdk/provisioning/Azure.Provisioning/tests/ProvisioningTests.cs index c5fdaeb5b579f..aa9378f31d45e 100644 --- a/sdk/provisioning/Azure.Provisioning/tests/ProvisioningTests.cs +++ b/sdk/provisioning/Azure.Provisioning/tests/ProvisioningTests.cs @@ -212,20 +212,10 @@ await ValidateBicepAsync( } [RecordedTest] - public async Task SqlServerDatabaseWithAutoAddedParent() + public void SqlServerDatabaseThrowsWithoutParent() { TestInfrastructure infrastructure = new TestInfrastructure(configuration: new Configuration { UseInteractiveMode = true }); - _ = new SqlDatabase(infrastructure); - infrastructure.Build(GetOutputPath()); - - await ValidateBicepAsync( - parameters: BinaryData.FromObjectAsJson( - new - { - administratorLogin = new { value = "admin" }, - administratorPassword = new { value = "password" } - }), - interactiveMode: true); + Assert.Throws(() => new SqlDatabase(infrastructure)); } [RecordedTest] @@ -317,6 +307,13 @@ await ValidateBicepAsync( interactiveMode: true); } + [RecordedTest] + public void PostgreSqlDatabaseThrowsWithoutParent() + { + TestInfrastructure infrastructure = new TestInfrastructure(configuration: new Configuration { UseInteractiveMode = true }); + Assert.Throws(() => new PostgreSqlFlexibleServerDatabase(infrastructure)); + } + [RecordedTest] public async Task CosmosDB() { From 12e52b95b52937baac6bc4a5e2c41f969d709e63 Mon Sep 17 00:00:00 2001 From: jolov Date: Thu, 7 Mar 2024 09:44:00 -0800 Subject: [PATCH 3/5] use const --- sdk/provisioning/Azure.Provisioning/assets.json | 2 +- .../src/postgresql/PostgreSqlFirewallRule.cs | 7 +++---- .../src/postgresql/PostgreSqlFlexibleServer.cs | 5 +++-- .../src/postgresql/PostgreSqlFlexibleServerDatabase.cs | 9 +++++---- .../tests/Infrastructure/PostgreSql/main.bicep | 6 +++--- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/sdk/provisioning/Azure.Provisioning/assets.json b/sdk/provisioning/Azure.Provisioning/assets.json index e93933e11ace8..0d14a523af821 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_31fa1a137f" + "Tag": "net/provisioning/Azure.Provisioning_bff795fd6e" } \ No newline at end of file diff --git a/sdk/provisioning/Azure.Provisioning/src/postgresql/PostgreSqlFirewallRule.cs b/sdk/provisioning/Azure.Provisioning/src/postgresql/PostgreSqlFirewallRule.cs index 5952fdcb3f41f..6039cbeb27693 100644 --- a/sdk/provisioning/Azure.Provisioning/src/postgresql/PostgreSqlFirewallRule.cs +++ b/sdk/provisioning/Azure.Provisioning/src/postgresql/PostgreSqlFirewallRule.cs @@ -5,8 +5,6 @@ using System.Net; using Azure.ResourceManager.PostgreSql; using Azure.ResourceManager.PostgreSql.Models; -using Azure.ResourceManager.Sql; -using Azure.ResourceManager.Sql.Models; namespace Azure.Provisioning.PostgreSql { @@ -16,6 +14,7 @@ namespace Azure.Provisioning.PostgreSql public class PostgreSqlFirewallRule : Resource { private const string ResourceTypeName = "Microsoft.DBforPostgreSQL/flexibleServers/firewallRules"; + private const string DefaultVersion = "2023-03-01-preview"; private static readonly Func Empty = (name) => ArmPostgreSqlModelFactory.PostgreSqlFirewallRuleData(); /// @@ -27,7 +26,7 @@ public class PostgreSqlFirewallRule : Resource /// The parent. /// The name. /// The version. - public PostgreSqlFirewallRule(IConstruct scope, string? startIpAddress = default, string? endIpAddress = default, PostgreSqlFlexibleServer? parent = default, string name = "fw", string version = "2023-03-01-preview") + public PostgreSqlFirewallRule(IConstruct scope, string? startIpAddress = default, string? endIpAddress = default, PostgreSqlFlexibleServer? parent = default, string name = "fw", string version = DefaultVersion) : this(scope, parent, name, version, false, (name) => ArmPostgreSqlModelFactory.PostgreSqlFirewallRuleData( name: name, resourceType: ResourceTypeName, @@ -36,7 +35,7 @@ public PostgreSqlFirewallRule(IConstruct scope, string? startIpAddress = default { } - private PostgreSqlFirewallRule(IConstruct scope, PostgreSqlFlexibleServer? parent = default, string name = "fw", string version = "2023-03-01-preview", bool isExisting = false, Func? creator = null) + private PostgreSqlFirewallRule(IConstruct scope, PostgreSqlFlexibleServer? parent = default, string name = "fw", string version = DefaultVersion, bool isExisting = false, Func? creator = null) : base(scope, parent, name, ResourceTypeName, version, creator ?? Empty, isExisting) { } diff --git a/sdk/provisioning/Azure.Provisioning/src/postgresql/PostgreSqlFlexibleServer.cs b/sdk/provisioning/Azure.Provisioning/src/postgresql/PostgreSqlFlexibleServer.cs index caeac06102b6f..5bd39c6f6784e 100644 --- a/sdk/provisioning/Azure.Provisioning/src/postgresql/PostgreSqlFlexibleServer.cs +++ b/sdk/provisioning/Azure.Provisioning/src/postgresql/PostgreSqlFlexibleServer.cs @@ -16,6 +16,7 @@ namespace Azure.Provisioning.PostgreSql public class PostgreSqlFlexibleServer : Resource { private const string ResourceTypeName = "Microsoft.DBforPostgreSQL/flexibleServers"; + private const string DefaultVersion = "2023-03-01-preview"; private static readonly Func Empty = (name) => ArmPostgreSqlFlexibleServersModelFactory.PostgreSqlFlexibleServerData(); /// @@ -50,7 +51,7 @@ public PostgreSqlFlexibleServer( string? availabilityZone = default, ResourceGroup? parent = default, string name = "postgres", - string version = "2021-06-01", + string version = DefaultVersion, AzureLocation? location = default) : this(scope, parent, name, version, false, (name) => ArmPostgreSqlFlexibleServersModelFactory.PostgreSqlFlexibleServerData( name: name, @@ -74,7 +75,7 @@ private PostgreSqlFlexibleServer( IConstruct scope, ResourceGroup? parent = default, string name = "postgres", - string version = "2020-06-01", + string version = DefaultVersion, bool isExisting = false, Func? creator = null) : base(scope, parent, name, ResourceTypeName, version, creator ?? Empty, isExisting) diff --git a/sdk/provisioning/Azure.Provisioning/src/postgresql/PostgreSqlFlexibleServerDatabase.cs b/sdk/provisioning/Azure.Provisioning/src/postgresql/PostgreSqlFlexibleServerDatabase.cs index e4476ff9700ad..522b1e169c955 100644 --- a/sdk/provisioning/Azure.Provisioning/src/postgresql/PostgreSqlFlexibleServerDatabase.cs +++ b/sdk/provisioning/Azure.Provisioning/src/postgresql/PostgreSqlFlexibleServerDatabase.cs @@ -13,6 +13,7 @@ namespace Azure.Provisioning.PostgreSql public class PostgreSqlFlexibleServerDatabase : Resource { private const string ResourceTypeName = "Microsoft.DBforPostgreSQL/flexibleServers/databases"; + private const string DefaultVersion = "2023-03-01-preview"; private static readonly Func Empty = (name) => ArmPostgreSqlFlexibleServersModelFactory.PostgreSqlFlexibleServerDatabaseData(); @@ -26,8 +27,8 @@ public class PostgreSqlFlexibleServerDatabase : Resource ArmPostgreSqlFlexibleServersModelFactory.PostgreSqlFlexibleServerDatabaseData(name: name)) { } @@ -35,8 +36,8 @@ public PostgreSqlFlexibleServerDatabase( private PostgreSqlFlexibleServerDatabase( IConstruct scope, PostgreSqlFlexibleServer? parent = default, - string name = "postgres", - string version = "2020-06-01", + string name = "db", + string version = DefaultVersion, bool isExisting = false, Func? creator = null) : base(scope, parent, name, ResourceTypeName, version, creator ?? Empty, isExisting) diff --git a/sdk/provisioning/Azure.Provisioning/tests/Infrastructure/PostgreSql/main.bicep b/sdk/provisioning/Azure.Provisioning/tests/Infrastructure/PostgreSql/main.bicep index afa53b164f66a..2d0fdc22dadfd 100644 --- a/sdk/provisioning/Azure.Provisioning/tests/Infrastructure/PostgreSql/main.bicep +++ b/sdk/provisioning/Azure.Provisioning/tests/Infrastructure/PostgreSql/main.bicep @@ -20,7 +20,7 @@ param serverEdition string param p string = 'name' -resource postgreSqlFlexibleServer_mZ8PC2Gce 'Microsoft.DBforPostgreSQL/flexibleServers@2021-06-01' = { +resource postgreSqlFlexibleServer_mZ8PC2Gce 'Microsoft.DBforPostgreSQL/flexibleServers@2023-03-01-preview' = { name: toLower(take(concat('postgres', uniqueString(resourceGroup().id)), 24)) location: location sku: { @@ -41,9 +41,9 @@ resource postgreSqlFlexibleServer_mZ8PC2Gce 'Microsoft.DBforPostgreSQL/flexibleS } } -resource postgreSqlFlexibleServerDatabase_ZKSktt9cR 'Microsoft.DBforPostgreSQL/flexibleServers/databases@2021-06-01' = { +resource postgreSqlFlexibleServerDatabase_GXcWWJhWh 'Microsoft.DBforPostgreSQL/flexibleServers/databases@2023-03-01-preview' = { parent: postgreSqlFlexibleServer_mZ8PC2Gce - name: 'postgres' + name: 'db' properties: { } } From 51bfdb0f7e2985f228ca1a2ced36842dc2dbf5a9 Mon Sep 17 00:00:00 2001 From: jolov Date: Thu, 7 Mar 2024 09:52:22 -0800 Subject: [PATCH 4/5] api --- .../Azure.Provisioning/api/Azure.Provisioning.net6.0.cs | 4 ++-- .../api/Azure.Provisioning.netstandard2.0.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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 f43170aebfb01..768160c1d3b93 100644 --- a/sdk/provisioning/Azure.Provisioning/api/Azure.Provisioning.net6.0.cs +++ b/sdk/provisioning/Azure.Provisioning/api/Azure.Provisioning.net6.0.cs @@ -284,14 +284,14 @@ public partial class PostgreSqlFirewallRule : Azure.Provisioning.Resource { - public PostgreSqlFlexibleServer(Azure.Provisioning.IConstruct scope, Azure.Provisioning.Parameter administratorLogin, Azure.Provisioning.Parameter administratorPassword, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerSku? sku = null, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerVersion? serverVersion = default(Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerVersion?), Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerHighAvailability? highAvailability = null, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerStorage? storage = null, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerDataEncryption? encryption = null, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerBackupProperties? backup = null, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerNetwork? network = null, string? availabilityZone = null, Azure.Provisioning.ResourceManager.ResourceGroup? parent = null, string name = "postgres", string version = "2021-06-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 PostgreSqlFlexibleServer(Azure.Provisioning.IConstruct scope, Azure.Provisioning.Parameter administratorLogin, Azure.Provisioning.Parameter administratorPassword, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerSku? sku = null, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerVersion? serverVersion = default(Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerVersion?), Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerHighAvailability? highAvailability = null, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerStorage? storage = null, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerDataEncryption? encryption = null, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerBackupProperties? backup = null, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerNetwork? network = null, string? availabilityZone = null, Azure.Provisioning.ResourceManager.ResourceGroup? parent = null, string name = "postgres", string version = "2023-03-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 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; } } public partial class PostgreSqlFlexibleServerDatabase : Azure.Provisioning.Resource { - public PostgreSqlFlexibleServerDatabase(Azure.Provisioning.IConstruct scope, Azure.Provisioning.PostgreSql.PostgreSqlFlexibleServer? parent = null, string name = "postgres", string version = "2021-06-01") : base (default(Azure.Provisioning.IConstruct), default(Azure.Provisioning.Resource), default(string), default(Azure.Core.ResourceType), default(string), default(System.Func)) { } + public PostgreSqlFlexibleServerDatabase(Azure.Provisioning.IConstruct scope, Azure.Provisioning.PostgreSql.PostgreSqlFlexibleServer? parent = null, string name = "db", string version = "2023-03-01-preview") : 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.PostgreSql.PostgreSqlFlexibleServerDatabase FromExisting(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.PostgreSql.PostgreSqlFlexibleServer? parent) { throw null; } } 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 f43170aebfb01..768160c1d3b93 100644 --- a/sdk/provisioning/Azure.Provisioning/api/Azure.Provisioning.netstandard2.0.cs +++ b/sdk/provisioning/Azure.Provisioning/api/Azure.Provisioning.netstandard2.0.cs @@ -284,14 +284,14 @@ public partial class PostgreSqlFirewallRule : Azure.Provisioning.Resource { - public PostgreSqlFlexibleServer(Azure.Provisioning.IConstruct scope, Azure.Provisioning.Parameter administratorLogin, Azure.Provisioning.Parameter administratorPassword, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerSku? sku = null, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerVersion? serverVersion = default(Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerVersion?), Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerHighAvailability? highAvailability = null, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerStorage? storage = null, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerDataEncryption? encryption = null, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerBackupProperties? backup = null, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerNetwork? network = null, string? availabilityZone = null, Azure.Provisioning.ResourceManager.ResourceGroup? parent = null, string name = "postgres", string version = "2021-06-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 PostgreSqlFlexibleServer(Azure.Provisioning.IConstruct scope, Azure.Provisioning.Parameter administratorLogin, Azure.Provisioning.Parameter administratorPassword, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerSku? sku = null, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerVersion? serverVersion = default(Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerVersion?), Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerHighAvailability? highAvailability = null, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerStorage? storage = null, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerDataEncryption? encryption = null, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerBackupProperties? backup = null, Azure.ResourceManager.PostgreSql.FlexibleServers.Models.PostgreSqlFlexibleServerNetwork? network = null, string? availabilityZone = null, Azure.Provisioning.ResourceManager.ResourceGroup? parent = null, string name = "postgres", string version = "2023-03-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 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; } } public partial class PostgreSqlFlexibleServerDatabase : Azure.Provisioning.Resource { - public PostgreSqlFlexibleServerDatabase(Azure.Provisioning.IConstruct scope, Azure.Provisioning.PostgreSql.PostgreSqlFlexibleServer? parent = null, string name = "postgres", string version = "2021-06-01") : base (default(Azure.Provisioning.IConstruct), default(Azure.Provisioning.Resource), default(string), default(Azure.Core.ResourceType), default(string), default(System.Func)) { } + public PostgreSqlFlexibleServerDatabase(Azure.Provisioning.IConstruct scope, Azure.Provisioning.PostgreSql.PostgreSqlFlexibleServer? parent = null, string name = "db", string version = "2023-03-01-preview") : 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.PostgreSql.PostgreSqlFlexibleServerDatabase FromExisting(Azure.Provisioning.IConstruct scope, string name, Azure.Provisioning.PostgreSql.PostgreSqlFlexibleServer? parent) { throw null; } } From 2dc160e49736ad1b621b6b6e4c90fe1aa449b723 Mon Sep 17 00:00:00 2001 From: jolov Date: Thu, 7 Mar 2024 10:46:18 -0800 Subject: [PATCH 5/5] change default api version --- sdk/provisioning/Azure.Provisioning/assets.json | 2 +- .../src/postgresql/PostgreSqlFlexibleServer.cs | 2 +- .../src/postgresql/PostgreSqlFlexibleServerDatabase.cs | 5 ++--- .../tests/Infrastructure/PostgreSql/main.bicep | 4 ++-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/sdk/provisioning/Azure.Provisioning/assets.json b/sdk/provisioning/Azure.Provisioning/assets.json index 0d14a523af821..85e3a9d830347 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_bff795fd6e" + "Tag": "net/provisioning/Azure.Provisioning_8f78e8f800" } \ No newline at end of file diff --git a/sdk/provisioning/Azure.Provisioning/src/postgresql/PostgreSqlFlexibleServer.cs b/sdk/provisioning/Azure.Provisioning/src/postgresql/PostgreSqlFlexibleServer.cs index 5bd39c6f6784e..8c4e93c70ee7e 100644 --- a/sdk/provisioning/Azure.Provisioning/src/postgresql/PostgreSqlFlexibleServer.cs +++ b/sdk/provisioning/Azure.Provisioning/src/postgresql/PostgreSqlFlexibleServer.cs @@ -16,7 +16,7 @@ namespace Azure.Provisioning.PostgreSql public class PostgreSqlFlexibleServer : Resource { private const string ResourceTypeName = "Microsoft.DBforPostgreSQL/flexibleServers"; - private const string DefaultVersion = "2023-03-01-preview"; + internal const string DefaultVersion = "2022-12-01"; private static readonly Func Empty = (name) => ArmPostgreSqlFlexibleServersModelFactory.PostgreSqlFlexibleServerData(); /// diff --git a/sdk/provisioning/Azure.Provisioning/src/postgresql/PostgreSqlFlexibleServerDatabase.cs b/sdk/provisioning/Azure.Provisioning/src/postgresql/PostgreSqlFlexibleServerDatabase.cs index 522b1e169c955..6ca454d5efa91 100644 --- a/sdk/provisioning/Azure.Provisioning/src/postgresql/PostgreSqlFlexibleServerDatabase.cs +++ b/sdk/provisioning/Azure.Provisioning/src/postgresql/PostgreSqlFlexibleServerDatabase.cs @@ -13,7 +13,6 @@ namespace Azure.Provisioning.PostgreSql public class PostgreSqlFlexibleServerDatabase : Resource { private const string ResourceTypeName = "Microsoft.DBforPostgreSQL/flexibleServers/databases"; - private const string DefaultVersion = "2023-03-01-preview"; private static readonly Func Empty = (name) => ArmPostgreSqlFlexibleServersModelFactory.PostgreSqlFlexibleServerDatabaseData(); @@ -28,7 +27,7 @@ public PostgreSqlFlexibleServerDatabase( IConstruct scope, PostgreSqlFlexibleServer? parent = null, string name = "db", - string version = DefaultVersion) + string version = PostgreSqlFlexibleServer.DefaultVersion) : this(scope, parent, name, version, false, (name) => ArmPostgreSqlFlexibleServersModelFactory.PostgreSqlFlexibleServerDatabaseData(name: name)) { } @@ -37,7 +36,7 @@ private PostgreSqlFlexibleServerDatabase( IConstruct scope, PostgreSqlFlexibleServer? parent = default, string name = "db", - string version = DefaultVersion, + string version = PostgreSqlFlexibleServer.DefaultVersion, bool isExisting = false, Func? creator = null) : base(scope, parent, name, ResourceTypeName, version, creator ?? Empty, isExisting) diff --git a/sdk/provisioning/Azure.Provisioning/tests/Infrastructure/PostgreSql/main.bicep b/sdk/provisioning/Azure.Provisioning/tests/Infrastructure/PostgreSql/main.bicep index 2d0fdc22dadfd..e5f45c832b1dd 100644 --- a/sdk/provisioning/Azure.Provisioning/tests/Infrastructure/PostgreSql/main.bicep +++ b/sdk/provisioning/Azure.Provisioning/tests/Infrastructure/PostgreSql/main.bicep @@ -20,7 +20,7 @@ param serverEdition string param p string = 'name' -resource postgreSqlFlexibleServer_mZ8PC2Gce 'Microsoft.DBforPostgreSQL/flexibleServers@2023-03-01-preview' = { +resource postgreSqlFlexibleServer_mZ8PC2Gce 'Microsoft.DBforPostgreSQL/flexibleServers@2022-12-01' = { name: toLower(take(concat('postgres', uniqueString(resourceGroup().id)), 24)) location: location sku: { @@ -41,7 +41,7 @@ resource postgreSqlFlexibleServer_mZ8PC2Gce 'Microsoft.DBforPostgreSQL/flexibleS } } -resource postgreSqlFlexibleServerDatabase_GXcWWJhWh 'Microsoft.DBforPostgreSQL/flexibleServers/databases@2023-03-01-preview' = { +resource postgreSqlFlexibleServerDatabase_GXcWWJhWh 'Microsoft.DBforPostgreSQL/flexibleServers/databases@2022-12-01' = { parent: postgreSqlFlexibleServer_mZ8PC2Gce name: 'db' properties: {