Search code examples
powershellazure-web-app-serviceazure-app-service-plans

How to get associated AppServicePlan associated with AppService (WebJob) using PowerShell


I am trying to get AppServicePlan associated with an AppService (WebJob) using PowerShell.

I tried below 2 cmdlets but am not getting the what I need.

Get-AzWebApp -ResourceGroupName $azResource.ResourceGroupName -Name $azResource.Name
Get-AzAppServicePlan

Can someone tell me how to get the associated AppServicePlan of a AppService (WebJob) using PowerShell.


Solution

  • I assume from what you say, that you already know your App Service Name then and the resource group where the resources are:

    Connect-AzAccount # Will depend on how you connect, interactively or not
    $appServiceName = "YourAppServiceName" # Replace with your App Service name
    $resourceGroupName = "YourResourceGroupName" # Replace with your Resource Group Name
    $appService = Get-AzWebApp -ResourceGroupName $resourceGroupName -Name $appServiceName
    $appServicePlan = Get-AzAppServicePlan -ResourceGroupName $resourceGroupName | Where-Object { $_.Id -eq $appService.ServerFarmId }
    

    You should get the Service Plan linked to the App Service in question.