Skip to content

Web Hosting Plan APIs

Suwat Ch edited this page Jan 21, 2021 · 13 revisions

List Web Hosting Plans for a subscription (Web Hosting Plan is synonym Server Farm).

ARMClient.exe get /subscriptions/{subscription}/providers/Microsoft.Web/serverFarms?api-version=2014-11-01

List Web Hosting Plans for a resource group

ARMClient.exe get /subscriptions/{subscription}/resourceGroups/{resourceGroup}/providers/Microsoft.Web/serverFarms?api-version=2014-11-01

Get Web Hosting Plan

ARMClient.exe get /subscriptions/{subscription}/resourceGroups/{resourceGroup}/providers/Microsoft.Web/serverFarms/{planName}?api-version=2014-11-01

Create Web Hosting Plan

ARMClient.exe put /subscriptions/{subscription}/resourceGroups/{resourceGroup}/providers/Microsoft.Web/serverFarms/{planName}?api-version=2014-11-01 @payload.json

Example payload.json to create Web Hosting Plan.

{
  "location": "{location}",
  "properties": {
    "sku": "(Free|Shared|Basic|Standard)", (Optional)
    "numberOfWorkers": "(int32)", (Optional)
    "workerSize": "(Small|Medium|Large)", (Optional)
    "hostingEnvironment": "(string)", (Optional)
    "adminSiteName": "(string)" (Optional)
  }
}

Note: {hostingEnvironment} if omitted, will create serverFarm on the cloud env. Otherwise, it will create serverFarm in that hosting environment stamp.

Update Web Hosting Plan

ARMClient.exe put /subscriptions/{subscription}/resourceGroups/{resourceGroup}/providers/Microsoft.Web/serverFarms/{planName}?api-version=2014-11-01 @payload.json

Example payload.json file to set adminSiteName.

{
  "location": "{location}",
  "properties": {
    "adminSiteName": "{siteName}"
  }
}

List sites Web Hosting Plan

ARMClient.exe get "/subscriptions/{subscription}/resourceGroups/{resourceGroup}/providers/Microsoft.Web/serverFarms/{planName}/sites?api-version=2014-11-01"

Only running sites
ARMClient.exe get "/subscriptions/{subscription}/resourceGroups/{resourceGroup}/providers/Microsoft.Web/serverFarms/{planName}/sites?api-version=2014-11-01&$filter=state eq 'running'"

Only non-running sites
ARMClient.exe get "/subscriptions/{subscription}/resourceGroups/{resourceGroup}/providers/Microsoft.Web/serverFarms/{planName}/sites?api-version=2014-11-01&$filter=state ne 'running'"

Restart sites in the Web Hosting Plan

ARMClient.exe post "/subscriptions/{subscription}/resourceGroups/{resourceGroup}/providers/Microsoft.Web/serverFarms/{planName}/restartSites?api-version=2014-11-01&softRestart=True"

Reboot a worker in the Web Hosting Plan

ARMClient.exe post "/subscriptions/{subscription}/resourceGroups/{resourceGroup}/providers/Microsoft.Web/serverFarms/{planName}/workers/{ipAddress_OR_computerName}/reboot?api-version=2014-11-01"

List workers running webapp

ARMClient.exe get "/subscriptions/{subscription}/resourceGroups/{resourceGroup}/providers/Microsoft.Web/sites/{siteName}/instances?api-version=2014-11-01"

Delete Web Hosting Plan

ARMClient.exe delete /subscriptions/{subscription}/providers/Microsoft.Web/serverFarms/{planName}?api-version=2014-11-01
Clone this wiki locally