Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/Sql/Sql/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Additional information about change #1
-->
## Upcoming Release
Fix New-AzSqlDatabaseSecondary cmdlet to check for PartnerDatabaseName existence instead of DatabaseName existence.

## Version 2.1.2
* Fix vulnerability assessment set baseline cmdlets functionality to work on master db for azure database and limit it on managed instance system databases.
Expand Down
15 changes: 13 additions & 2 deletions src/Sql/Sql/Replication/Cmdlet/NewAzureSqlDatabaseSecondary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ protected override IEnumerable<AzureReplicationLinkModel> GetEntity()
// We try to get the database. Since this is a create secondary database operation, we don't want the secondary database to already exist
try
{
ModelAdapter.GetDatabase(this.PartnerResourceGroupName, this.PartnerServerName, this.DatabaseName);
ModelAdapter.GetDatabase(this.PartnerResourceGroupName, this.PartnerServerName, GetEffectivePartnerDatabaseName(this.DatabaseName, this.PartnerDatabaseName));
}
catch (CloudException ex)
{
Expand Down Expand Up @@ -195,7 +195,7 @@ protected override IEnumerable<AzureReplicationLinkModel> ApplyUserInputToModel(
DatabaseName = this.DatabaseName,
PartnerResourceGroupName = this.PartnerResourceGroupName,
PartnerServerName = this.PartnerServerName,
PartnerDatabaseName = string.IsNullOrWhiteSpace(this.PartnerDatabaseName) ? this.DatabaseName : this.PartnerDatabaseName,
PartnerDatabaseName = GetEffectivePartnerDatabaseName(this.DatabaseName, this.PartnerDatabaseName),
SecondaryElasticPoolName = this.SecondaryElasticPoolName,
AllowConnections = this.AllowConnections,
Tags = TagsConversionHelper.CreateTagDictionary(Tags, validate: true),
Expand Down Expand Up @@ -240,5 +240,16 @@ protected override IEnumerable<AzureReplicationLinkModel> PersistChanges(IEnumer
ModelAdapter.CreateLinkWithNewSdk(entity.First().PartnerResourceGroupName, entity.First().PartnerServerName, entity.First())
};
}

/// <summary>
/// Returns the partner database name to be used in request based on input
/// </summary>
/// <param name="database">Source database name</param>
/// <param name="partnerDatabase">Partner database name if given</param>
/// <returns>The input entity</returns>
private string GetEffectivePartnerDatabaseName(string database, string partnerDatabase)
{
return string.IsNullOrEmpty(partnerDatabase) ? database : partnerDatabase;
}
}
}