-
Notifications
You must be signed in to change notification settings - Fork 4k
Fixing SQL Import Export issue with Managed Identity #28285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Thanks for your contribution! The pull request validation has started. Please revisit this comment for updated status. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes an issue with SQL Import/Export cmdlets when using Managed Identity authentication where the password parameter was required even though it's not needed for this authentication type.
- Made the
AdministratorLoginPassword
parameter optional in the base cmdlet class - Updated the service adapter to only decrypt and set the password when not using Managed Identity authentication
- Updated unit tests to reflect the parameter changes
Reviewed Changes
Copilot reviewed 8 out of 34 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
ImportExportCmdletArmBase.cs |
Made AdministratorLoginPassword parameter optional by removing Mandatory=true and ValidateNotNullOrEmpty attributes |
ImportExportDatabaseAdapter.cs |
Added conditional logic to only set password when authentication type is not ManagedIdentity |
AzureSqlDatabaseImportExportTests.cs |
Updated unit tests to expect AdministratorLoginPassword as non-mandatory parameter |
ChangeLog.md |
Added changelog entries documenting the fix for both export and import cmdlets |
Other test files | Updated test session records and test scripts (not core to the PR's functionality) |
src/Sql/Sql/ChangeLog.md
Outdated
* Fixed `New-AzSqlDatabaseExport` to use SQL Authentication with ManagedIdentity without any manadatory password | ||
* Fixed `New-AzSqlDatabaseImport` to use SQL Authentication with ManagedIdentity without any manadatory password |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a spelling error: 'manadatory' should be 'mandatory'.
* Fixed `New-AzSqlDatabaseExport` to use SQL Authentication with ManagedIdentity without any manadatory password | |
* Fixed `New-AzSqlDatabaseImport` to use SQL Authentication with ManagedIdentity without any manadatory password | |
* Fixed `New-AzSqlDatabaseExport` to use SQL Authentication with ManagedIdentity without any mandatory password | |
* Fixed `New-AzSqlDatabaseImport` to use SQL Authentication with ManagedIdentity without any mandatory password |
Copilot uses AI. Check for mistakes.
src/Sql/Sql/ChangeLog.md
Outdated
* Fixed `New-AzSqlDatabaseExport` to use SQL Authentication with ManagedIdentity without any manadatory password | ||
* Fixed `New-AzSqlDatabaseImport` to use SQL Authentication with ManagedIdentity without any manadatory password |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a spelling error: 'manadatory' should be 'mandatory'.
* Fixed `New-AzSqlDatabaseExport` to use SQL Authentication with ManagedIdentity without any manadatory password | |
* Fixed `New-AzSqlDatabaseImport` to use SQL Authentication with ManagedIdentity without any manadatory password | |
* Fixed `New-AzSqlDatabaseExport` to use SQL Authentication with ManagedIdentity without any mandatory password | |
* Fixed `New-AzSqlDatabaseImport` to use SQL Authentication with ManagedIdentity without any mandatory password |
Copilot uses AI. Check for mistakes.
@@ -81,6 +81,11 @@ public AzureSqlDatabaseImportExportBaseModel Export(AzureSqlDatabaseImportExport | |||
parameters.AuthenticationType = exportRequest.AuthenticationType.ToString().ToLowerInvariant(); | |||
} | |||
|
|||
if (exportRequest.AuthenticationType != AuthenticationType.ManagedIdentity) | |||
{ | |||
parameters.AdministratorLoginPassword = AzureSqlServerAdapter.Decrypt(exportRequest.AdministratorLoginPassword); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider checking if AdministratorLoginPassword is null before attempting to decrypt it, as making the parameter optional means it could be null even for non-ManagedIdentity authentication types.
parameters.AdministratorLoginPassword = AzureSqlServerAdapter.Decrypt(exportRequest.AdministratorLoginPassword); | |
if (!string.IsNullOrEmpty(exportRequest.AdministratorLoginPassword)) | |
{ | |
parameters.AdministratorLoginPassword = AzureSqlServerAdapter.Decrypt(exportRequest.AdministratorLoginPassword); | |
} |
Copilot uses AI. Check for mistakes.
@@ -124,6 +129,11 @@ public AzureSqlDatabaseImportExportBaseModel ImportNewDatabase(AzureSqlDatabaseI | |||
parameters.AuthenticationType = importRequest.AuthenticationType.ToString().ToLowerInvariant(); | |||
} | |||
|
|||
if (importRequest.AuthenticationType != AuthenticationType.ManagedIdentity) | |||
{ | |||
parameters.AdministratorLoginPassword = AzureSqlServerAdapter.Decrypt(importRequest.AdministratorLoginPassword); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider checking if AdministratorLoginPassword is null before attempting to decrypt it, as making the parameter optional means it could be null even for non-ManagedIdentity authentication types.
parameters.AdministratorLoginPassword = AzureSqlServerAdapter.Decrypt(importRequest.AdministratorLoginPassword); | |
if (importRequest.AdministratorLoginPassword != null) | |
{ | |
parameters.AdministratorLoginPassword = AzureSqlServerAdapter.Decrypt(importRequest.AdministratorLoginPassword); | |
} |
Copilot uses AI. Check for mistakes.
/azp run azure-powershell - security-tools |
Azure Pipelines successfully started running 1 pipeline(s). |
Description
There exists an issue with Import Export using Managed Identity where it asks for SQL Authentication Password even though it is not required. This PR fixes the issue by making the password parameter from the Import Export cmdlet optional
Mandatory Checklist
Please choose the target release of Azure PowerShell. (⚠️ Target release is a different concept from API readiness. Please click below links for details.)
Check this box to confirm: I have read the Submitting Changes section of
CONTRIBUTING.md
and reviewed the following information:ChangeLog.md
file(s) appropriatelysrc/{{SERVICE}}/{{SERVICE}}/ChangeLog.md
.## Upcoming Release
header in the past tense.ChangeLog.md
if no new release is required, such as fixing test case only.