Has anything changed on the endpoints handling get-azwebapp requests?
I have a Azure DevOps pipeline running several tasks. one of which grants access to a keyvault for WebApps matching a particular Tag. Let say: Tag:"Env" with Value:"Dev".
I used to run this code:
$webapps = Get-AzWebApp | where {$_.Tags.Item('env') -match "dev"}
foreach($webapp in $webapps){
$faMid = $webapp.Identity.PrincipalId
Set-AzKeyVaultAccessPolicy -VaultName $(kvName) -ObjectId $faMid -PermissionsToSecrets "get","list"
}
In a step in azure devops. $(kvName) is a devops variable containing the name of the keyvault I want to update.
For testing purposes I change this to a sting containing the name of the keyvault.
When I run
$webapps = Get-AzWebApp | where {$_.Tags.Item('env') -match "dev"} I get an error:
You cannot call a method on a null-valued expression.
At line:1 char:34
+ ... = Get-AzWebApp | where {$_.Tags.Item('env') -eq "dev"}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
But when I run Get-AzWebApp | where {$_.Tags.Item('env') -match "dev"}
a result set containing the webapps I need is return perfectly.
Just putting $webapps = in front of the working code breaks it.
I have tried this on my own development machine with the latest az cmdlets and on our deployment server.
Both fail.
I ran this pipeline just last week without any issue but today I failed without any change to the code.
Any thoughts?
Using Powershell 5.1 and Az Module 5.6.0