Force restart your Azure App service site and host
Tags: webdev, azure, devops, cloud
Published: 2021-06-22 12:21:18

---
title: Force restart your Azure App service site and host
published: true
date: 22/06/2021
tags: #webdev #azure #devops #cloud
canonical_url: https://darraghoriordan.com/2021/06/22/force-restart-azure-app-service-host/
---

Sometimes your Azure App service host will need to be restarted. You can do this but it’s hidden away in the Azure resource manager site. Here’s how to find it!

<!-- end excerpt -->
## Why restart the host

Sometimes your app service host can get into a broken state or you want make sure that it is in a fresh state.

For example I had to do this recently when trying to upgrade an App Services site to Node 14 and it failed because PM2 was missing on the App Service Linux container.

You might see errors like this that the App service instance doesn’t recover from

```
[error]Error: Failed to swap App Service 'YOUR_SITE' slots - 'staging' and 'production'. Error: ExpectationFailed - Cannot swap site slots for site 'YOUR_SITE' because the 'staging' slot did not respond to http ping. (CODE: 417)
```

Or

```
[error]Error: Failed to swap App Service 'YOUR_SITE' slots - 'staging' and 'production'. Error: Conflict - Cannot modify this site because another operation is in progress. Details: Id: 45210a29, OperationName: SwapSiteSlots, CreatedTime: 5/20/2021 2:01:30 AM, WebSystemName: websites, SubscriptionName: , WebspaceName: YOUR_SITE, SiteName: ***, SlotName: staging, ServerFarmName: , GeoOperationId: (null) (CODE: 409)
```

## Azure resource manager

Azure provides a nice ARM interface of all your resources at [https://resources.azure.com](https://resources.azure.com).

If you work with Azure resources then it’s worth getting familiar with this interface - you can use it to quickly extract ARM template details, you can easily update settings and fully manage the resources you have access to using the Azure Api through the website.

## Find the App Service Resource

To find the app service resource you have to dig in to the tree menu on the left. The path is:

Subscriptions > YOUR\_SUBSCRIPTION > resourceGroups > YOUR\_RESOURCE\_GROUP > providers > Microsoft.Web > sites > YOUR\_SITE

and select the site name. Make sure you select the site name! You should see something like

```
{
  "id": "/subscriptions/...",
  "name": "YOUR_SITE",
  "type": "Microsoft.Web/sites",

```

Note if you are trying to restart a slot you need to go a step further in the tree:

Subscriptions > YOUR\_SUBSCRIPTION > resourceGroups > YOUR\_RESOURCE\_GROUP > providers > Microsoft.Web > sites > YOUR\_SITE > slots > YOUR\_SLOT\_NAME

## Change the interface to edit mode

Click the big `Edit` button!

[![Edit button](https://darraghoriordan.com/static/24e314f190ce1ae5c04eb2e695b031d1/0acb4/editButton.png "Edit button")](/static/24e314f190ce1ae5c04eb2e695b031d1/0acb4/editButton.png)<figcaption>Edit button</figcaption>

## How to turn off the site instance

Find the section below and change “Running” to “Stopped”

```
 "properties": {
    "name": "YOUR_SITE",
    "state": "Running",
    "hostNames": [
      "YOUR_SITE.azurewebsites.net"
    ],


 "properties": {
    "name": "YOUR_SITE",
    "state": "Stopped",
    "hostNames": [
      "YOUR_SITE.azurewebsites.net"
    ],

```

## Turn off the App Services host

You have to find this setting and change it to true

```
    "scmSiteAlsoStopped": false,

    "scmSiteAlsoStopped": true,
```

## Save

To save your changes click on the PUT button.