I am working on a process to automatically remove and add databases to Azure. When the database isn't in use, it can be removed from Azure and placed in cheaper S3 storage as a .bacpac
.
I am using SqlPackage.exe from Microsoft as a PowerShell script to export and import these databases from and to Azure respectively in either direction. I invoke it via a Python script to use boto3.
The issue I have is with the down direction at step 3. The sequence would be:
- Download the Azure SQL DB to a
.bacpac
(can be achieved with SqlPackage.exe) - Upload this
.bacpac
to cheaper S3 storage (using boto3 Python SDK) - Delete the Azure SQL Database (It appears the Azure Blob Python SDK can't help me, and it appears SQLPackage.exe does not have a delete function)
Is step 3 impossible to automate with a script? Could a workaround be to SqlPackage.exe import a small dummy .bacpac
with the same name to overwrite the old bigger DB?
Thanks.
CodePudding user response:
To remove an Azure SQL Database using PowerShell, you will need to use Remove-AzSqlDatabase
Cmdlet.
To remove an Azure SQL Database using Azure CLI, you will need to us az sql db delete
.
If you want to write code in Python to delete the database, you will need to use Azure SDK for Python
.