In the past few months at GorillaStack our main focus has been on improving support for the Azure platform. Adding to the list of recent announcements for new Azure features we are excited to release three new Actions in our Rules Engine to manage the lifecycle of Azure SQL Databases and help users further reduce their cloud spend.
Azure SQL Databases are charged at an hourly rate while they are provisioned, even while they are stopped. In order to reduce spend, they will need to be deleted.
The Export Azure SQL Databases export Action gives users the ability to export an SQL Database as a
.bacpac file to be stored in Azure Blob Storage. It also supports a “Wait for Export” option to allow synchronous execution when used in a sequence with other Actions. When the “Wait for Export” option is enabled, a maximum wait time can also be specified. If the maximum wait time is reached before confirmation of the export success, the Action will be marked as failed.
By default, all created
.bacpac files will be retained in Azure Blob Storage indefinitely. This behavior can be overridden by disabling the “Retain all exports” option, which will cause the Action to delete any old
.bacpac files for the targeted database, retaining only the most recent export.
The Delete Azure SQL Databases Action will delete SQL Databases, and supports resource targeting by tags or by name. While there are some niche cases when this Action may be useful on its own, we expect it to be used in a sequence with the Export SQL Databases Action. Utilizing the wait option on the export Action ensure that the export operation completes successfully before the database is deleted.
The Restore Azure SQL Databases Action will create a new SQL Database and import a stored
.bacpac file to it. The
.bacpac file used to restore a database must have been created by the GorillaStack Export SQL Databases Action. Similar to the export Action, it supports a “Wait for import” option to allow synchronous execution when used in a sequence with other Actions.
Azure SQL Databases being used in non-production environments, or for internal tooling that does not necessitate 24/7 uptime, are ideal candidates for these three new Actions. When paired with a Schedule type trigger, these Actions enable databases to be deleted temporarily when they are not needed (e.g. outside of office hours), and fully restored once more as necessary. With the wait parameter enabled on the export Action, a Rule with an Action sequence of “Export Azure SQL Databases” -> “Delete Azure SQL Databases” will ensure the export operation has successfully completed before continuing with database deletion.
The export and restore Actions will require some additional setup compared to our existing Rules Engine Actions. The underlying methods used to execute these Actions require admin credentials to the databases being affected.
For security reasons, we will not store these credentials within GorillaStack. To work around this limitation, the export and restore Actions will invoke an Azure Function in the targeted Azure subscription, where the admin credentials will be stored in Azure Key Vault. This way the database admin credentials will never be read outside of your own Azure account.
To make the Action setup as seamless as possible, we provide a setup script to be run once per database being targeted. This script can be run either in PowerShell or Azure Cloud Shell, and will create all the required resources for the Actions to be performed. For a more in-depth explanation on this setup and the resources that will be created, check out the documentation for the new Actions.