简体   繁体   中英

Azure SQL Database sandbox based on production

I have a large Azure Sql Database. I need to provide a sandbox to a team that is a copy of the database, but allows them to create sql objects. The data in the sandbox needs to be up to date with production. I used elastic queries, but the performance is not ideal. I've looked at data sync, but the company requires AD authentication. Restoring production periodically as the sandbox is not ideal as the team does not want to lose their work. Any suggestions? I'm sure I must be overlooking something.

I would first make a copy the production database, then create a "From the Hub" sync group.

1. Copy Database

You can easily create a copy of an Azure SQL database by going to the database blade and clicking "Copy" in the header. From there it will ask you the new database name and target server. You can put it on the same server or create a new server, that is up to you.

https://docs.microsoft.com/en-us/azure/sql-database/sql-database-copy

Once you've done that, you now have a "sandbox" database you control which would be an exact copy of production.

2. Sync Group

After that, you can sync specific tables from production to the sandbox by creating a Azure SQL "Sync Group".

  • You want to initiate this from your production database since that is the source (or hub) database, so go to the database blade of your production database and choose "Sync to other databases".
  • Click on "New Sync Group". From there it will ask you for a sync group name which could be something like "SyncSandbox".
  • Select your member database(s), this would be your sandbox database, so choose "Use Existing Database" and select your sandbox database.
  • Choose your sync direction. This is important , since you only want to sync from production to the sandbox, select "From the Hub".
  • Finally you can configure the sync group. On the Tables page, select a database from the list of sync group members and select Refresh schema. Once you're done, select Save. You can also go into the properties and select the sync frequency if you want it automatic.

https://docs.microsoft.com/en-us/azure/sql-database/sql-database-get-started-sql-data-sync

The only one thing worry me that you mentioned your team want to keep their work. I dont know how it would be possible imagine you copy database and your team created new customer with new id which is lets say 31 and then same thing will happens on production so how to resolve those conflicts. If to omit this then I would recommend you to do following.

  1. Setup database replication
  2. Create job Logic App or Azure function which will execute command on that replica

CREATE DATABASE Database2 AS COPY OF Database1;

  1. I am not sure but you probably will need to run command make this database writable since if you copy replica it will be read only.
  2. Run script to replace all sensitive data.

But keep in mind that you will have down time so probably better would be to do this job every morning so when team starts they will have fresh data

More options how to COPY

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM