question

AgustinVazquez-8249 avatar image
0 Votes"
AgustinVazquez-8249 asked bhargaviannadevara-msft edited

Retrieve blue slot webjob status

Hello,

I am trying to find a way to pull the webjob status from a webapp blue slot
I have already tried using:

  • az cli: gives information about the blue slot name but not the status
    $BlueSlotStatus = az webapp webjob continuous list --name "$($WebApp.WebApp)/blue" --resource-group $WebApp.ResourceGroup | ConvertFrom-Json

  • powershell AzureRM: I get the blue slot status but nothing related to the webjob in that slot
    $BlueSlotStatus = Get-AzureRmResource -ResourceGroupName $WebApp.ResourceGroup -ResourceName "$($WebApp.WebApp)/blue" -ResourceType Microsoft.Web/sites/slots

The ideal situation would be using AzureRM modules. I found this stack overflow post but it's using Get-AzureWebsiteJob which is a really old command and needs Select-AzureSubscription command, so I would have 2 different commands in the same script to change the subscription and I do not like that approach
https://stackoverflow.com/questions/40400457/how-to-list-all-running-webjobs-within-an-azure-subscription-using-powershell

Any other idea?

Thanks for the help !

azure-webappsazure-webapps-webjobs
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

bhargaviannadevara-msft avatar image
0 Votes"
bhargaviannadevara-msft answered bhargaviannadevara-msft edited

@AgustinVazquez-8249 The az webapp webjob continuous list command also takes in a --slot parameter that you can use to pass in the name of the slot to list its webjobs and their status.

Try this:

az webapp webjob continuous list --name <app-name> --resource-group <rg-name> --slot qa

Sample Output:

115313-image.png


EDIT:
Currently, there are no AzureRm or Az cmdlets available to manage Web Jobs, although it has been a highly requested feature.
You can follow the discussion and add your comments here: https://github.com/Azure/azure-powershell/issues/661

That said, if a PS + REST API approach would work for you, the following can help:

# Invoke the "Web Apps - List Web Jobs Slot" REST API
$uri = 'https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<rg-name>/providers/Microsoft.Web/sites/<app-name>/slots/qa/webjobs?api-version=2019-08-01'

$response = Invoke-RestMethod -Uri $uri -Method Get -Headers $authHeader
foreach ($webjob in $response.value)
{
    Write-Output $webjob.Properties`n
}

The above snippet would produce similar output as the CLI command.
Reference: Web Apps - List Web Jobs Slot

Hope this helps. Do let us know if you have any additional questions.



If an answer is helpful, please "Accept answer" and/or "Up-Vote" which might help other community members reading this thread.


image.png (202.9 KiB)
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for the answer, it worked ! I have moved everything to az cli

Just to know, is there any way to do this with AzureRM or Az Modules?

1 Vote 1 ·

@AgustinVazquez-8249 Thanks for confirming, glad that helped!
I've updated my response with more details and a workaround for PowerShell. Please check.

0 Votes 0 ·

Thank you Again !

Have a nice day

1 Vote 1 ·