Skip to content

Fixing SQL Import Export issue with Managed Identity. #27965

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

debalinaroy
Copy link
Contributor

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

  • SHOULD update ChangeLog.md file(s) appropriately
    • Update src/{{SERVICE}}/{{SERVICE}}/ChangeLog.md.
      • A snippet outlining the change(s) made in the PR should be written under the ## Upcoming Release header in the past tense.
    • Should not change ChangeLog.md if no new release is required, such as fixing test case only.
  • SHOULD regenerate markdown help files if there is cmdlet API change. Instruction
  • SHOULD have proper test coverage for changes in pull request.
  • SHOULD NOT adjust version of module manually in pull request

@Copilot Copilot AI review requested due to automatic review settings June 16, 2025 03:36
Copy link

Thanks for your contribution! The pull request validation has started. Please revisit this comment for updated status.

Copy link
Contributor

@Copilot Copilot AI left a 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 where the SQL administrator password was still required when using Managed Identity for Import/Export operations by making the password parameter optional in the cmdlet and adjusting the adapter logic.

  • Skip decryption and assignment of AdministratorLoginPassword when AuthenticationType is ManagedIdentity
  • Change AdministratorLoginPassword parameter in the cmdlet from mandatory to optional
  • Update SDK generation commit and add new input files in the README

Reviewed Changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 1 comment.

File Description
src/Sql/Sql/ImportExport/Service/ImportExportDatabaseAdapter.cs Conditionally assign AdministratorLoginPassword only for non-managed identities
src/Sql/Sql/ImportExport/Cmdlet/ImportExportCmdletArmBase.cs Made AdministratorLoginPassword parameter optional
src/Sql/Sql.Management.Sdk/README.md Bumped commit and added new input-file entries
Comments suppressed due to low confidence (3)

src/Sql/Sql/ImportExport/Cmdlet/ImportExportCmdletArmBase.cs:83

  • Introduce distinct parameter sets or conditional parameter binding so that AdministratorLoginPassword remains mandatory for SQL Authentication scenarios and only optional for ManagedIdentity, preventing runtime confusion.
[Parameter(Mandatory = false, HelpMessage = "The Azure SQL Server administrator password")]

src/Sql/Sql/ImportExport/Cmdlet/ImportExportCmdletArmBase.cs:83

  • After changing the parameter to optional, regenerate the cmdlet help markdown files so that the documentation reflects the new optional status of AdministratorLoginPassword.
[Parameter(Mandatory = false, HelpMessage = "The Azure SQL Server administrator password")]

src/Sql/Sql/ImportExport/Service/ImportExportDatabaseAdapter.cs:84

  • Add unit tests covering the ManagedIdentity code path in both Import and Export methods to verify that AdministratorLoginPassword is not required and is correctly skipped.
if (exportRequest.AuthenticationType != AuthenticationType.ManagedIdentity)

@@ -59,7 +59,7 @@ public AzureSqlDatabaseImportExportBaseModel Export(AzureSqlDatabaseImportExport
ExportDatabaseDefinition parameters = new ExportDatabaseDefinition()
{
AdministratorLogin = exportRequest.AdministratorLogin,
AdministratorLoginPassword = AzureSqlServerAdapter.Decrypt(exportRequest.AdministratorLoginPassword),
AdministratorLoginPassword = null,
Copy link
Preview

Copilot AI Jun 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider removing the initial null assignment in the object initializer and only setting AdministratorLoginPassword inside the conditional block to reduce redundancy.

Suggested change
AdministratorLoginPassword = null,

Copilot uses AI. Check for mistakes.

@debalinaroy debalinaroy changed the title fixing import export bug Fixing SQL Import Export issue with Managed Identity. Jun 16, 2025
@vidai-msft
Copy link
Contributor

@debalinaroy Please fix the test failure and static analysis issue detected. When updating generated SDK, please check in all the updated files and avoid uploading those that are related to your code or API. That will definitely cause analysis failure.

@vidai-msft
Copy link
Contributor

In addition, please add release notes in the ChangeLog.md under the Upcoming Release section.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants