Configure a local sandbox DB from an AZ environment
Sometimes we need to create a sandbox environment to do some testing before we push it into our company main Dev repository, we need to do some unit testing while developing our database changes; to do so we need to replicate the testing environment to have it in our local machines. In the following note we will work with a cloud database from an Azure SQL that is in a serverless tier and will create a copy, prepare it for our container environment testing, connect it, and do some local tasks to poor in some data tests inside it.
These are the steps that will be followed to complete the task:
Configure you local sandbox DB from your AZ environment
As breifly explained at the begining we are going to start by connecting
Connect to Azure tenant
The first step that need to be done is to start by connecting to our Azure database, the necessary information needed is the server name so for that we can gather that information from:
- The Azure Portal
- The Azure CLI AZ DB command custommed query
Using the Azure Portal
Once connected to your Azure account and into the Azure portal, search for the SQL Databases
Look up for your server from the list, select it and find your database
Select the connection string option
Now take the connection string for the full name
Using the Azure CLI Terminal for custommed query
az login -u [YourUser] --tenant [if you have more than 1]
az sql server list --query "{name,fullyQualifiedDomainName}"
Retrieve results from Query parameter:
- Using ADS
First link your azure account into the ADS.
Expand your ADS Connections search for your server and connect
Generate BACPAC file and download to local machine
-
Using ADS
Install Database Admin Tool Extensions for Windows
On the targeted database choose the Data-tier Application wizard
Select the bacpac generation option in the admin tool extension and select the following option
Select destination and name for local bacpac file in your machine
Verify the task response from the panel on sucess operation
Create a container in local container management system
Find your Container image and use it, create your container
#Find your image and update your run command
docker image ls
#Create Container with mount using shared volume created
docker run -d -p 1433:1433 --name Daltanious --privileged -it \
--mount type="bind,src='shared-vol',dst='/mnt/SQL'" -v -e "SA_PASSWORD=Clave01*"\
-e "ACCEPT_EULA=Y" d04f
Connect and restore your bacpac binary
No hay comentarios:
Publicar un comentario