For a recent project, I was looking to automate the deployment of their Azure resources using Bicep.
Because of Bicep’s tight integration with Azure, I’ve typically found deploying and configuring Azure services straightforward.
However, one service type I’d not previously deployed with Bicep was SaaS (Software-as-a-Service) services. Typically deployed via the Azure Marketplace, these allow 3rd party vendors to provide pre-built software applications or solutions. Here are some of the Marketplace offerings -
At the time of writing, there are currently 3,185 Marketplace offerings
In my case, I was looking to deploy a new SendGrid account to provide outbound email functionality for an Azure-hosted application —
When deployed manually via the MarketPlace, SendGrid looks like this in the Azure Portal -
Its properties contain minimal information, with a link to SendGrid’s management portal to configure the service. Essentially, it’s just a SendGrid account that we’re paying for via our Azure subscription.
Bicep deployment
So, a manual deployment is straightforward, but what about deploying via Bicep?
The template reference docs are usually the first place I’d look for resource definitions and their available parameters — however, the Microsoft.Saas/resources resource type isn’t even listed.
Furthermore, in the Portal, there’s no export ARM template option or a view JSON definition option allowing us to view the resource’s properties.
It turns out the solution is to view the SaaS deployment on the resource group itself -
From there, we can view the ARM template. Crucially, it provides us with the necessary parameters and configuration options we need for SendGrid —
Okay, now we’re cooking. Using this information, we can build out the Bicep definition in VScode that looks like this —
VScode doesn’t recognize the resource type, but let’s try and deploy anyway using the following AZ CLI command -
az deployment group create - resource-group saastest-uksouth-rg - name sendgrid - template-file .\sendgrid.bicep
Back in the Azure Portal, under Deployments, we can verify the deployment has completed —
Success! I’ve tested this with some other SaaS offerings, and this approach has worked well so far.
Summary
In summary, the steps to deploy a new SaaS service using Bicep are —
First, deploy the service manually via the Azure Portal
View the deployment template on the resource group to obtain the deployment parameters
Create the Bicep code with the required configuration and parameters.
Deploy the service using Bicep and delete the manually deployed service.
This approach also works if you’re using ARM templates instead of Bicep.
I hope you found this post useful — feedback and questions are always welcome.
Comentarios