woensdag 24 november 2021

Do you need to make test checks on your Azure Portal subscription which Azure Resources you have deployed in a Resource Group? Then I've made this Pester script to check the location of a resource.

  $resourcegroup = 'YOUR_REOURCE_GROUP'
  $resourcename = 'YOUR_RESOURCE_NAME'
  $resources = Get-AzResource -Name $resourcename -ResourceGroupName $resourcegroup  

  # Create an empty array
  $testcases = @()
  $resources.ForEach{$testcases += @{resource = $_}}

  Describe 'Azure Resources'{
       It "Gives correct region to <resource>" -TestCases $testcases  {              
              $resource.Location | Should -Be 'westeurope'      

What tool is Pester?

source: https://github.com/pester/Pester

video: https://www.youtube.com/watch?v=qeiy8fRMHf8&t

Geen opmerkingen:

Een reactie posten