Testing Logic App State
  • 20 May 2020
  • 1 Minute to read
  • Contributors
  • Comment
  • Dark
    Light
  • PDF

Testing Logic App State

  • Comment
  • Dark
    Light
  • PDF

Article Summary

Following on from the other articles in this section I now would like to add tests to ensure that the Logic Apps in my architecture are in the expected state.

In the below script I will query all of the logic apps in my resource group. I will then have a list of Logic Apps that are allowed to be disabled in the $disabledLogicApps variable. My script will iterate over the logic apps and will now check the logic apps are in the state I expect them to be in.

I will end up with 1 test for each thing I am checking in the test output so its easy to identify individual issues and fix them. Once all tests pass I know I am in a good place.




$logicApps = Get-AzLogicApp -ResourceGroupName $resourcegroup

Describe 'Logic App State'{
    
    #Logic Apps that are expected to be disabled
    $disabledLogicApps = New-Object "System.Collections.Generic.List[System.String]" 
    $disabledLogicApps.Add('LA-LogicApp1')
    $disabledLogicApps.Add('LA-LogicApp2')
    $disabledLogicApps.Add('LA-LogicApp3')
    
    foreach($logicApp in $logicApps)
    {        
        It "$($logicApp.Name) is the correct state" {
                        
            if($disabledLogicApps.Contains($logicApp.Name)){
                $logicApp.State | Should Be 'Disabled'
            }
            else{
                $logicApp.State | Should Be 'Enabled'
            }
        }       
    }    
}


Was this article helpful?