Having a hard time figuring out how to create an A...
# azure
Having a hard time figuring out how to create an Azure SQL Database by importing a bacpac file stored in a storage account. The Azure API has an endpoint for that: https://learn.microsoft.com/en-us/rest/api/sql/2022-05-01-preview/databases/import?tabs=HTTP Which is different than the create/update endpoint: https://learn.microsoft.com/en-us/rest/api/sql/2022-05-01-preview/databases/create-or-update?tabs=HTTP I'm using Python and have tried: •
◦ 1.103.0 ◦ 2.0.0b2 • Providing a blob URI to different parameters on
but those only accept Azure resource IDs ◦
• Multiple Azure API versions Furthermore, searching for the specific parameter names exposed by the
endpoint in the
module didn't give me anything: • storageKey / storage_key • storageUri / storage_uri • blobUri / blob_uri Is this API not represented in the SDK or do you know how to go about using
to do this?
I needed to solve a similar problem a while back and could not find a way to do what you describe (C# azure-native). What I ended up doing instead was creating an Azure database from the bapac manually, and using it as a source like you already pointed out. It seems that cloning speed is not related to database tier, so you can get away with a very cheap instance.
One workaround (although complicated) I can think of is a solution with a storage account, poweshell/other script and container instances. If you upload your bacpac to a storage account you should be able to mount it in a container instance together with a script that could run your database import/creation
I’d consider using Pulumi to manage the DB / infra itself, but use some other script/automation to orchestrate loading the data into the database (CI/CD, etc)).
@icy-doctor-13719 @rapid-engineer-94232 - Yeah I ended up spinning up an empty Azure SQL DB with Pulumi and then restored the bacpac with a script using the
cli. There's a caveat though, as bacpac imports have to be done during the initial provisioning of the DB as it has to be completely empty. The workaround to be able to restore from bacpac on a newly/already provisioned Azure SQL DB, as described here, is to drop all triggers, procedures, functions, tables, views etc. before running the sqlpackage bacpac import. A bit hacky IMO but worked out ok...