Home > OS >  Is it possible to check whether an azure app service is running using the Azure Management API?
Is it possible to check whether an azure app service is running using the Azure Management API?

Time:09-24

We have a demo application that is a docker image deployed to a Linux App Service on the Free App Service Plan SKU. It is used infrequently and as such it aggressively spins down. On the next activation it takes about 3-5 minutes to spin up the image. I would like to use the azure management api to check to see if the service is running to know whether the response should be in 3s or 200s. GET web seems the most appropriate API to call but the response shows that it is running, likely reflecting the state of the underlying app service plan. A trimmed response is below and gives the same whether the app is hot or cold.

Example Response

  "id": "/subscriptions/{subId}/resourceGroups/{rgName}/providers/Microsoft.Web/sites/{name}",
  "name": "{name}",
  "type": "Microsoft.Web/sites",
  "kind": "app,linux,container",
  "location": "East US",
  "properties": {
    "name": "{name}",
    "state": "Running",
    "webSpace": "ML-EastUSwebspace-Linux",
    "usageState": "Normal",

CodePudding user response:

It is not a Good practice to check from API Management if an Azure Service is running or not .

Only the following features are supported by Azure APIIM.

Best practice is to setup of alerts on critical application metrics.

Alerts are based on Action Groups that we configure to receive an Alert.

CodePudding user response:

I overlooked Web Apps - List Instance Identifiers but this is results in what I am looking for. When the app is spun down the list of identifiers is the empty set and conversely when active it has an identifier.

Spun Down

{
  "value": [],
  "nextLink": null,
  "id": null
}

Active

{
  "value": [
    {
      "id": "/subscriptions/{subid}/resourceGroups/{rgname}/providers/Microsoft.Web/sites/{name}/instances/81c6b43bcb7aea592e620086200b3ab40b78857d08aa07e29c330415afa10cf8",
      "name": "81c6b43bcb7aea592e620086200b3ab40b78857d08aa07e29c330415afa10cf8",
      "type": "Microsoft.Web/sites/instances",
      "location": "East US",
      "properties": {
        "state": "UNKNOWN",
        "name": "81c6b43bcb7aea592e620086200b3ab40b78857d08aa07e29c330415afa10cf8",
        "siteInstanceName": "81c6b43bcb7aea592e620086200b3ab40b78857d08aa07e29c330415afa10cf8",
        "statusUrl": "{url}",
        "detectorUrl": "{url}",
        "consoleUrl": "{url}",
        "healthCheckUrl": null,
        "machineName": "lw0sdlwk0006ZZ",
        "containers": null
      }
    }
  ],
  "nextLink": null,
  "id": null
}
  • Related