Database user password change in Azure SQL after Import bacpac

Prakash M, Bhanu 211 Reputation points
2022-07-28T18:21:14.573+00:00

On Prem:\

I have a db called db1
User test is having access to db1
Now I have exported bacpac

in Azure SQL Single DB:

Import bacpac file
Able to Connect with server admin and able to see db1 in Azure.

Issue: I wanted to connect with db user called Test and it is failed with login failure. I tried to reset the password and got below error. The parameter PASSWORD cannot be provided for users that cannot authenticate in a database.

Please help me, instead of dropping this db user and recreate any other way to make the connectivity with the test user? So that existing db objects will remain same in the database.

Please suggest

Azure SQL Database
0 comments No comments

Answer accepted by question author
Bhargava-MSFT 31,361 Reputation points Microsoft Employee Moderator
2022-08-04T19:13:42.02+00:00

Hi @Prakash M, Bhanu ,

Here are the steps you need to take once you import the DB using backpack file.

Once you import the backpack file from on-prem to Azure SQL, your login(serverlevel) and users(DBlevel) will be created.

The backpac holds the information of users. The passwords of these users are changed in the background due to security compliance.

You will need to reset the password once the backpack file is imported.

 on Master   
      
 CREATE USER testuser FROM LOGIN testuser ;  -- since the SQL account won't exist on the master DB   
  
once the user is created on the master DB, then change the password using the below command   
  
on master   
  
ALTER login testuser WITH PASSWORD = 'PasswordHere'  

You no need to drop the users or re-map the permissions again. The only extra steps are 1) create user on the master 2) reset login password

Before you run the commands, you can check the DB users and roles using the below command on the user DB.

 SELECT p2.name AS UserName,  
 STRING_AGG(p1.name, ', ') AS DatabaseRoleName  
 FROM sys.database_role_members AS m  
 RIGHT OUTER JOIN sys.database_principals AS p1  
  ON m.role_principal_id = p1.principal_id  
 LEFT OUTER JOIN sys.database_principals AS p2  
  ON m.member_principal_id = p2.principal_id  
 WHERE p2.name IS NOT NULL  
  AND p2.name NOT IN ('dbo')  
 GROUP BY p2.name  
 ORDER BY p2.name  

Hope this helps

------------------------------

  • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how
  • Want a reminder to come back and check responses? Here is how to subscribe to a notification
  • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators

Was this answer helpful?

1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.

    3 deleted comments

    Comments have been turned off. Learn more

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.