Friday, February 1, 2019

Enterprise Logic App ARM Template Deployment through PS

We had a requirement for automating integration platform deployment for my customer. The integration layer mainly consists of Logic Apps and azure resources.

The challenge was the number of environments we had. So we came up with the solution structure for different integrations as below. And then utilized our below automation script to deploy these logic apps through PowerShell.




PowerShell Script

# Login to Azure
Login-AzureRmAccount

# Select Subscription
$sub = '94xxyy9a-e0e4-4d04-a1df-54d091b9665c'
Select-AzureRmSubscription -SubscriptionId $sub

# Resource Group Name
$ResourceGroupName = "rg-aue-ms-dev"

# Environment Name
$env = 'MS-DEV'

# Project Name
$path = "C:\FLVSTS\D5\Non-native\Address Validation\FBS.Intgeration.ESAM\FBS.Intgeration.ESAM"

# Extract the name
$name = (Get-ChildItem -path $path *.json).Name

# Deploy each Logic App
foreach($TemplateName in $name)
{
$TemplateName = $TemplateName.Split('.')[0]
$TemplateFile = $path+'\'+"$TemplateName.json"
$TemplateParamFile = $path+'\'+$env+'\'+"$TemplateName.parameters.json"
New-AzureRmResourceGroupDeployment -Name ('ARM-Deployment' + '-' + ((Get-Date).ToUniversalTime()).ToString('HH-mm-ss')) `
                                -ResourceGroupName $ResourceGroupName `
                                -TemplateFile $TemplateFile `
                                -TemplateParameterFile $TemplateParamFile `
                                -Force -Verbose `
                                -ErrorVariable ErrorMessages

}


This was implemented during initial phase of the project. Later we utilized ARM Linked template feature coupled with Azure DevOps to automate this completely. Will cover this as part of another blog.

No comments:

Post a Comment

Azure Policy support for remediating tags for existing resources

Use Azure policy to remediate tags for existing resources. https://azure.microsoft.com/en-us/updates/azure-provides-at-scale-tags-managem...