Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Sunshine And March Vibes (2025 Wallpapers Edition)

      May 29, 2025

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      May 29, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      May 29, 2025

      How To Prevent WordPress SQL Injection Attacks

      May 29, 2025

      Gemini can now watch Google Drive videos for you – including work meetings

      May 29, 2025

      LG is still giving away a free 27-inch gaming monitor, but you’ll have to hurry

      May 29, 2025

      Slow Roku TV? This 30-second fix made my system run like new again

      May 29, 2025

      Hume’s new EVI 3 model lets you customize AI voices – how to try it

      May 29, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Your Agentforce Readiness Assessment

      May 29, 2025
      Recent

      Your Agentforce Readiness Assessment

      May 29, 2025

      Introducing N|Sentinel: Your AI-Powered Agent for Node.js Performance Optimization

      May 29, 2025

      FoalTS framework – version 5 is released

      May 29, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      KB5058499 finally makes Windows 11 24H2 stable for gaming, and it wasn’t Nvidia’s fault

      May 29, 2025
      Recent

      KB5058499 finally makes Windows 11 24H2 stable for gaming, and it wasn’t Nvidia’s fault

      May 29, 2025

      Transform Your Workflow With These 10 Essential Yet Overlooked Linux Tools You Need to Try

      May 29, 2025

      KNOPPIX is a bootable Live system

      May 29, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»Databases»Migrate logins, database roles, users, and object-level permissions from Azure SQL Database to Amazon RDS for SQL Server

    Migrate logins, database roles, users, and object-level permissions from Azure SQL Database to Amazon RDS for SQL Server

    May 24, 2024

    In this post, we demonstrate how to migrate SQL logins, database roles, users, and object-level permissions from Azure SQL Database to Amazon Relational Database Service (Amazon RDS) for SQL Server using T-SQL.

    Within SQL Server, a SQL login acts as a security principal, allowing a user or application to connect to a SQL Server instance. It serves as a mechanism to manage access, permissions, user privileges, and monitor database activities. Migrating SQL logins is crucial during a database migration because they contain authentication information, access rights, and permissions essential for users and applications to connect and interact with databases. While native backup and restore operations are often sufficient for login migration, certain scenarios require additional steps to ensure a seamless migration, especially when migrating from Azure SQL Database and using data transfer methods SmartbulkCopy, AWS Database Migration Service (AWS DMS), or BCP to migrate data and schema separately

    SQL Server security components overview

    In SQL Server, a SQL login is a security principal that allows a user or application to connect to an instance. These SQL logins are associated with user accounts for the purpose of authentication. Authentication in SQL Server involves three key elements:

    Principals – These are entities capable of requesting resources within SQL Server. Principal access levels are contingent on their scope. We can categorize principles into two types based on their scope: server-level principals and database-level principals.
    Securables – These are server or database objects to which authentication can be granted, such as tables or endpoints. Securables are further categorized based on their scope: server scoped, database scoped, and schema scoped.
    Permissions – Permissions define control of securables to the principal. Principals can run specific operations on securables based on the permissions assigned. At the server level, permissions are managed through logins and server roles, whereas at the database level, permissions are regulated using database users and roles.

    The following table illustrates the SQL Server security administration differences between Azure SQL Database and Amazon RDS for SQL Server.

    Activity
    Amazon RDS for SQL Server
    Azure SQL Database

    Where you manage server-level security
    Security folder in SQL Server Management Studio’s Object Explorer
    master database and through the Azure portal

    Windows Authentication
    AWS Managed Microsoft AD
    Azure Active Directory identities

    Server-level security role for creating logins
    securityadmin fixed server role
    loginmanager database role in the master database

    Commands for managing logins
    CREATE LOGIN, ALTER LOGIN, DROP LOGIN
    CREATE LOGIN, ALTER LOGIN, DROP LOGIN (there are some parameter limitations and you must be connected to the master database)

    View that shows all logins
    sys.server_principals
    sys.sql_logins (you must be connected to the master database)

    Server-level role for creating databases
    dbcreator fixed database role
    dbmanager database role in the master database

    Solution overview

    In scenarios where logins and user permissions are not migrated as part of the database migration process, such as when using SmartBulkCopy, AWS DMS, or BCP, we utilize the built-in generate script utility and T-SQL dynamic scripts to create the logins, roles, users, and object-level permissions for each database.

    The following diagram illustrates the high-level architecture of migrating logins and database users from Azure SQL Database to Amazon RDS for SQL Server.

    The following steps are involved to migrate the SQL logins and their dependent security components:

    Migrate logins and validate the existence of logins and the users between Azure SQL Database to Amazon RDS for SQL Server.
    Migrate server roles and server permissions and validate the permissions.
    Migrate users and database roles and validate the users and the roles.
    Migrate object-level permissions and validate the permissions.

    Prerequisites

    To get started, you need to have the following:

    An Azure SQL database as a source
    An RDS for SQL Server DB instance (Single-AZ or Multi-AZ) as a target
    Connectivity between Azure SQL Database to Amazon RDS for SQL Server
    A target RDS for SQL Server database with required user-defined objects (tables, views, functions, and stored procedures) and a user with the db_owner fixed database role to create objects in the SQL Server database
    An Azure login with minimum permissions to master to fetch login and user info like loginmanager, and more roles to make sure that the primary login name of Azure SQL Database is different from RDS for SQL Server

    Migrate logins

    You can access Azure SQL Database using a SQL Server authentication account, Microsoft Entra server principals, or a managed identity. Identify the Microsoft Entra server principals and managed identity by fetching the login information from sys.logins and migrate them manually. Ensure to create EXTERNAL_USERS as db_owner in Amazon RDS for SQL Server. Due to Amazon RDS for SQL Server’s permission restrictions, you cannot grant sysadmin privileges to users at the target

    To migrate SQL logins from Azure SQL Database to Amazon RDS for SQL Server, you can script out the create login scripts with a hashed password and SID. However, when using Azure SQL Database as the source, the generated SID and hashed password may cause conversion issues, and certain functions like SUSER_SID() are not supported.

    In this section, we explain how to generate the create a login script from a source SQL Server instance and migrate it to the target RDS for SQL Server instance.

    Connect to your source Azure SQL from SQL Server Manager Studio (SSMS) with the primary user or a user that has security admin fixed role permissions to script logins.
    In the SSMS query editor, choose the Results to Grid (press Ctrl+D) option.
    Run the following script from the new query window to generate the create logins script:

    –Script to generate create Logins
    Use master
    go
    SET NOCOUNT ON
    SELECT ‘BEGIN CREATE LOGIN ‘ +QUOTENAME(sqllogin.name)+
    CASE
    WHEN sqllogin.type_desc = ‘SQL_LOGIN’ THEN ‘ WITH PASSWORD = ‘ +CONVERT(NVARCHAR(MAX),sqllogin.password_hash,1)+ ‘ HASHED,’ +’ CHECK_EXPIRATION = ‘
    + CASE WHEN sqllogin.is_expiration_checked = 1 THEN ‘ON’ ELSE ‘OFF’ END +’, CHECK_POLICY = ‘ +CASE WHEN sqllogin.is_policy_checked = 1 THEN ‘ON,’ ELSE ‘OFF,’ END
    ELSE ‘ NOT_SQL_LOGIN’
    END
    +’ DEFAULT_DATABASE=[‘ +sqllogin.default_database_name+ ‘], DEFAULT_LANGUAGE=[‘ +sqllogin.default_language_name+ ‘] END;’
    AS [– Amazon RDS Logins Creation Script –]
    FROM sys.sql_logins AS sqllogin

    The output of the query provides the logins creation script.

    Copy the logins creation script and run it using the Amazon RDS primary user or a login with the “Alter any login” server-level securable that is part of a processadmin and setupadmin fixed server roles in the RDS for SQL Server instance.
    Check for any errors and fix them accordingly.
    Validate the number of logins created on the Azure SQL database and RDS for SQL Server database. To test the login if working properly, connect to RDS for SQL Server with any of the logins migrated with the password used to connect at the Azure SQL Database end.

    After the successful migration of logins, you can continue with the server role membership migration.

    You should be responsible and cautious while copying the output and pasting it at the target database because it contains sensitive data.

    Migrate server roles and server permissions

    In Amazon RDS for SQL Server, you don’t have superuser or sysadmin privileges. The primary user is the highest privilege user. Users cannot be created in the master database. User creation happens at the database level. The primary user is specified during RDS instance creation with a user name and password. The primary user has the maximum privileges allowed within RDS, but not full sysadmin privileges. Only setupadmin and processadmin fixed server roles can be granted to logins by the primary user. Refer to the fixed server roles in the RDS for SQL Server instance for more details.

    In Azure SQL Database, you can use the built-in server-level roles to manage permissions at the logical server level rather than granting permissions directly at that level. Refer to Azure SQL Database server roles for permission management for more details.

    The key steps to migrate server-level roles and permissions from Azure SQL Database to an RDS for SQL Server instance are as follows:

    For each login, identify the server-level roles they are a member of using the following script:

    SELECT m.name AS MemberName, r.name AS RoleName
    FROM sys.server_role_members rm
    JOIN sys.sql_logins m ON rm.member_principal_id = m.principal_id
    JOIN sys.server_principals r ON rm.role_principal_id = r.principal_id

    After the logins are created in Amazon RDS for SQL Server, you can recreate the server roles for setupadmin and processadmin on the RDS instance, because other roles are not possible. Refer Azure SQL Database server roles for permission management and Microsoft Entra server principals for AD users. You can add the login as a member to the processadmin and setupadmin fixed server roles on RDS using the following statements:

    ALTER SERVER ROLE [processadmin] ADD MEMBER [<RDSLoginName>]
    GO
    ALTER SERVER ROLE [setupadmin] ADD MEMBER [<RDSLoginName>]
    GO

    Refer to the permissions for the processadmin and setupadmin fixed server roles before manually adding logins to these roles on Amazon RDS.

    Migrate users and database roles

    To migrate your users and database roles, complete the following steps:

    Connect to your source Azure SQL from SSMS with the primary user or user that has security admin fixed role permissions.
    Choose (right-click) the database and choose Generate Scripts.
    Choose Next.

    Select Select specific database objects, then select Users.
    Choose Next.

    Select Save as script file.
    Enter a location to save the file.
    Choose Next.

    A script will be generated in the provided location.
    Run the copied script on the target RDS for SQL Server database.
    Validate the number of users, roles, and permissions on the Azure SQL database and match them with the RDS for SQL Server database by querying and joining the system tables sys.database_principals, database_role_members, database_role_members, and sys.database_permissions.

    Migrate object-level permissions

    Complete the following steps to migrate object-level permissions:

    Connect to your source Azure SQL from SSMS with the primary user or user that has security admin fixed role permissions to script logins.
    In the SSMS query editor, choose the Results to Grid (press Ctrl+D) option.
    Run the following script from the new query window to generate the object-level permissions create script:

    USE <database_Name>
    — Migrate the Server level permissions
    Select state_desc + ‘ ‘ + permission_name + ‘ ON [‘ + SCHEMA_NAME(SysObj.schema_id) + ‘].[‘+OBJECT_NAME(DBP.major_id)
    +’] TO [‘ + USER_NAME(DBP.grantee_principal_id) + ‘]’+ ‘; ‘ [–Command to add object-level Permissions–]
    from sys.database_permissions DBP INNER JOIN sys.database_principals DBPS ON DBP.grantee_principal_id=DBPS.principal_id Inner Join sys.objects SysObj ON SysObj.object_id=DBP.major_id
    where DBPS.name not in (‘public’,’dbo’)

    Run the created object-level permissions script on the target RDS for SQL Server database and validate.
    Connect to the target Amazon RDS for SQL Server using SSMS and copy the output scripts generated in Step 4.
    Validate the script output for any errors.

    Clean up

    To avoid future charges, remove all of the components you created while testing this use case by completing the following steps:

    On the Amazon RDS console, choose Databases in the navigation pane.
    Select the databases you set up and on the Actions menu, choose Delete.
    Enter delete me to confirm deletion.

    For more information about deleting an instance, refer to Deleting a DB instance.

    Conclusion

    In this post, we described how to migrate logins, database roles, users, and object-level permissions to Amazon RDS for SQL Server using T-SQL. If you have any questions or suggestions, leave a comment.

    About the Authors

    InduTeja Aligeti is a Senior Lead Database Consultant at AWS. She has over 18 years of experience working with Microsoft technologies with a specialization in SQL Server. She focuses on helping customers build highly available, cost-effective database solutions and migrate their large-scale SQL Server databases to AWS.

    Jitendra Kumar is a Lead Database Migration Consultant with AWS Professional Services. He helps customers migrate and modernize workloads in the AWS Cloud, with a special focus on modern application architectures and development best practices.

    Ramesh Babu Donti is a Lead Database Consultant with AWS Professional Services based out of Hyderabad, India. He focuses on helping customers build highly available, cost-effective database solutions and migrate their large-scale databases to AWS.

    Source: Read More

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleChoose the right change data capture strategy for your Amazon DynamoDB applications
    Next Article Researcher Indicates PCTattletale Stalkerware Found on US Hotels, Corporate and Law Firm Computers Leaks Recordings

    Related Posts

    Development

    How to Build an AI-Powered Cooking Assistant with Flutter and Gemini

    May 29, 2025
    Development

    Learn Python for Data Science – Full Course for Beginners

    May 29, 2025
    Leave A Reply Cancel Reply

    Continue Reading

    2 Perficient Healthcare Projects Awarded for Internet Site Excellence

    Development

    Recurrent Drafter for Fast Speculative Decoding in Large Language Models

    Development

    CVE-2025-22157 – Atlassian Jira Privilege Escalation Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    The latest Windows 11 update did not end support for older Intel chips. Here’s the source of the confusion.

    News & Updates

    Highlights

    Development

    Threat Actors Exploit Microsoft SmartScreen Vulnerability: Cyble Researchers

    July 6, 2024

    Cyble Research and Intelligence Labs (CRIL) researchers have uncovered an active campaign exploiting a Microsoft…

    Some of Call of Duty: Warzone’s biggest players use this weapon optic, so I tried it — it totally changed the game

    April 29, 2025

    CVE-2025-42605 – Meon Bidding Solutions Remote Authorization Bypass Vulnerability

    April 23, 2025

    How teams tap into the power of design with Figma Slides

    March 20, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.