Testing Logic Apps Governance
  • Updated on 20 May 2020
  • 1 minute to read
  • Contributors
  • Print
  • Comments
  • Share
  • Dark
    Light

Testing Logic Apps Governance

  • Print
  • Comments
  • Share
  • Dark
    Light

Continuing my articles about Pester testing my Azure infrastructure to ensure its in adherence to our standards I now want to look at my Logic Apps and check they are good.

In this case I want to ensure the following:

  • Every logic app should be in westus2
  • All logic apps should have a name that starts with LA-
  • If a logic app uses an Integration Account then it should be the right one for this environment

Like in previous articles I can get the list of logic apps and then I use the Describe pester keyword for the test class decleration. I will then loop over the logic apps and use the It keyword to have a bunch of tests for each logic app. In the case below my 3 tests (It) will result in 300 tests because I have 100 logic apps. Each test will show like a proper test case so I can easily manage fixing issues.

$logicApps = Get-AzLogicApp -ResourceGroupName $resourcegroup
$integrationAccountName = 'IA-DEV'

Describe 'Logic Apps'{
        
    foreach($logicApp in $logicApps)
    {                
        It "$($logicApp.Name) should be in westus2" {            
            $logicApp.Location | Should Be 'westus2'
        }

        It "$($logicApp.Name) should meet the naming convention" {               
            $logicApp.Name.StartsWith('LA-') | Should Be $true            
        }

        It "$($logicApp.Name) should be using a valid integration account" {   
            if($logicApp.IntegrationAccount -ne $null){                                 
                $logicApp.IntegrationAccount.Name | Should Be $integrationAccountName
            }
        }
    }    
}
Was this article helpful?