Skip to content

Commit c8658ea

Browse files
author
OJDUDE
committed
SQL Server IaaS Extension cmdlets update
1. Don't print or attempt to print private settings from the Get. Instead print *** if the options are set. 2. Print a message to educate the user when disabling Azure key vault that existing credentials will not be removed but AKV status will not be reported. 3. Update the help file. 4. No new tests are required as the current tests already cover the changes in this changeset.
1 parent a0473e0 commit c8658ea

File tree

3 files changed

+821
-506
lines changed

3 files changed

+821
-506
lines changed

src/ServiceManagement/Compute/Commands.ServiceManagement/IaaS/Extensions/SqlServer/GetAzureVMSqlServerExtension.cs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ internal void ExecuteCommand()
5555

5656
return this.GetExtensionContext(r);
5757
}), true);
58-
}
58+
}
5959

6060
protected override void ProcessRecord()
6161
{
@@ -69,7 +69,7 @@ protected override void ProcessRecord()
6969
/// <returns></returns>
7070
private VirtualMachineSqlServerExtensionContext GetExtensionContext(ResourceExtensionReference r)
7171
{
72-
string extensionName= VirtualMachineSqlServerExtensionCmdletBase.ExtensionPublishedNamespace + "."
72+
string extensionName = VirtualMachineSqlServerExtensionCmdletBase.ExtensionPublishedNamespace + "."
7373
+ VirtualMachineSqlServerExtensionCmdletBase.ExtensionPublishedName;
7474

7575
VirtualMachineSqlServerExtensionContext context = new VirtualMachineSqlServerExtensionContext
@@ -162,7 +162,7 @@ private VirtualMachineSqlServerExtensionContext GetExtensionContext(ResourceExte
162162
NSM.DeploymentSlot.Production);
163163
}
164164
catch (CloudException e)
165-
{
165+
{
166166
if (e.Response.StatusCode != HttpStatusCode.NotFound)
167167
{
168168
throw;
@@ -231,7 +231,11 @@ private AutoBackupSettings DeSerializeAutoBackupSettings(string category, string
231231
autoBackupSettings.RetentionPeriod = publicAutoBackupSettings.RetentionPeriod;
232232
autoBackupSettings.StorageAccessKey = "***";
233233
autoBackupSettings.StorageUrl = "***";
234-
autoBackupSettings.Password = "***";
234+
235+
if (autoBackupSettings.EnableEncryption)
236+
{
237+
autoBackupSettings.Password = "***";
238+
}
235239
}
236240
}
237241
catch (JsonReaderException jre)
@@ -246,7 +250,7 @@ private AutoBackupSettings DeSerializeAutoBackupSettings(string category, string
246250
}
247251

248252
private KeyVaultCredentialSettings DeSerializeKeyVaultCredentialSettings(string category, string input)
249-
{
253+
{
250254
KeyVaultCredentialSettings kvtSettings = new KeyVaultCredentialSettings();
251255

252256
if (!string.IsNullOrEmpty(input))
@@ -256,13 +260,17 @@ private KeyVaultCredentialSettings DeSerializeKeyVaultCredentialSettings(string
256260
// we only print the public settings
257261
PublicKeyVaultCredentialSettings publicSettings = JsonConvert.DeserializeObject<PublicKeyVaultCredentialSettings>(input);
258262

259-
if(publicSettings != null)
263+
if (publicSettings != null)
260264
{
261265
kvtSettings.CredentialName = publicSettings.CredentialName;
262266
kvtSettings.Enable = publicSettings.Enable;
263-
kvtSettings.ServicePrincipalName = "***";
264-
kvtSettings.ServicePrincipalSecret = "***";
265-
kvtSettings.AzureKeyVaultUrl = "***";
267+
268+
if (kvtSettings.Enable)
269+
{
270+
kvtSettings.ServicePrincipalName = "***";
271+
kvtSettings.ServicePrincipalSecret = "***";
272+
kvtSettings.AzureKeyVaultUrl = "***";
273+
}
266274
}
267275
}
268276
catch (JsonReaderException jre)

src/ServiceManagement/Compute/Commands.ServiceManagement/IaaS/Extensions/SqlServer/SetAzureVMSqlServerExtension.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ protected override void ProcessRecord()
110110
internal void ExecuteCommand()
111111
{
112112
ValidateParameters();
113+
114+
if ((this.KeyVaultCredentialSettings != null) && !this.KeyVaultCredentialSettings.Enable)
115+
{
116+
WriteVerboseWithTimestamp("SQL Server Azure key vault disabled. Previously configured credentials are not removed but no status will be reported");
117+
}
118+
113119
RemovePredicateExtensions();
114120
AddResourceExtension();
115121
WriteObject(VM);

0 commit comments

Comments
 (0)