Joe.wang Joe.wang - 3 months ago 16
PowerShell Question

Determine if Azure Deployments exist for the Specified Service and Slot

I'd like to know if it is possible to determine if a deployment is present for a given service (and the respective slot (

Production
or
Staging
)).

All I found would be to call
Get-AzureDeployment -ServiceName xxxservice
which would throw an error saying
Get-AzureDeployment : ResourceNotFound: No deployments were found.
in PowerShell.

Answer

try -ErrorVariable and -ErrorAction parameters

$deployment = Get-AzureDeployment -ServiceName $serviceName -Slot $slot -ErrorVariable a -ErrorAction silentlycontinue 
if ($a[0] -ne $null)
{
    Write-Output "$(Get-Date –f $timeStampFormat) - No deployment is detected."
}
Comments