I’m encountering an issue when running the get-AzWebApp command in powershell. All I’m trying to do is get a list of the web apps in a particular resource group, then check that they’re in a running state.
The command
$Apps = Get-AzWebApp -ResourceGroupName "<my group name>"
There are only 8 web apps in this RG, but every time I run it, it takes a good minute or so to run, but then fails with the following error ..
The script failed due to call depth overflow.
+ CategoryInfo : InvalidOperation: (0:Int32) [AppServiceStatusCheck_Test.ps1], RuntimeException
+ FullyQualifiedErrorId : CallDepthOverflow
Any ideas on how to resolve this would be great.
2
Answers
You can accomplish that using the below snippet but you will need
az cli
installed.Az webapp documentation:
https://learn.microsoft.com/en-us/cli/azure/webapp?view=azure-cli-latest#az-webapp-list
Az installation instructions:
https://learn.microsoft.com/en-us/powershell/azure/install-az-ps?view=azps-8.0.0
If you google the error
The script failed due to call depth overflow
you get some examples which suggest that either the syntax or the logic within your script is not quite correct or causing an infinite loop of some descritpion.The error is surfaced from
AppServiceStatusCheck_Test.ps1
. Do you have more context in that script that you can provide?As an alternative to GeralexGR suggestion using PowerShell commands and
Search-AzGraph
.If I am just querying Azure I tend to use a Kusto query with
Search-AzGraph
for speed of complex queries if your dataset is quite large. You can also cheat and find the resources in the portal then click the ‘Open Query’ to get what you need.