Deploying an ARM Template for Ocotpus Deploy

57 Views Asked by At

I have an IaC deployment implemented as a GitHub action, and I need to move it to Octopus Deploy.

My first azure arm template that creates a resource group. However, the built-in Deploy an Azure Resource Manager template step requires a resource group when I am setting it up. I don't have a resource group; my ARM is creating it.

My deployment will do more than create a resource group. I also have ARMs to create all the resources inside the group. For these, I can't specify the resource group when setting up the process because it is creat as part of the deployment.

1

There are 1 best solutions below

0
benPearce On

On the ARM step, turn on the Custom Deployment Scripts (via the Configure Features button).

In the pre-deploy script add the following script:

Get-AzureRmResourceGroup -Name $name -ErrorVariable notPresent -ErrorAction SilentlyContinue;

if ($notPresent) {
  New-AzureRmResourceGroup -Name $name -Location "WestUS" 
}

Not tested, taken from https://octopus.com/blog/dynamic-infrastructure#the-deployment-process