Share via


App Service JSON examples

Create Or Update example

To create or update an app, run the Create Or Update API with a JSON like the following in the request body. Note that serverFarmId must point to an existing App Service plan.

    {
        "name": "unique-app-name",
        "location": "West Europe",
        "properties": {
            "serverFarmId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resource-group-name/providers/Microsoft.Web/serverfarms/plan-name"
        }
    }

Create Or Update Configuration example

To update the PHP runtime version, run the Create Or Update Configuration API or Create Or Update Configuration Slot API with a JSON like the following in the request body:

    {
        "properties": {
            "phpVersion": "5.6"
        }
    }

Create Or Update Source Control example

To enable source control from GitHub, run the Create Or Update Source Control API or Create Or Update Source Control Slot API with a JSON like the following in the request body. Note that "isManualIntegration": true turns off continuous integration, which is required if you are deploying from someone else's public repo, like an Azure sample.

    {
        "properties": {
            "repoUrl": "https://github.com/Azure-Samples/app-service-web-html-get-started",
            "branch": "master",
            "isManualIntegration": true
        }
    }

Update Application Settings example

To update the app setting for your app, run the Update Application Settings API or Update Application Settings Slot API with a JSON like the following in the request body. Note that it should include all app settings, not just the ones you want to update.

    {
        "properties": {
            "WEBSITE_NODE_DEFAULT_VERSION": "4.2.3",
            "mysetting": "somevalue"
        }
    }

Update Connection Strings example

To update the connection strings for your app, run the Update Connection Strings API or Update Connection Strings Slot API with a JSON like the following in the request body. This code includes an example of each supported connection string type. Note that your request body should include all connection strings in your app, not just the ones you want to update.

    {
        "properties": {
            "sqldbconn": {
                "value": "connection-string-value",
                "type": "SQLAzure"
            },
            "sqlserverconn": {
                "value": "connection-string-value",
                "type": "SQLServer"
            },
            "mysqlconn": {
                "value": "connection-string-value",
                "type": "MySql"
            },
            "customconn": {
                "value": "connection-string-value",
                "type": "Custom"
            }
        }
    }

Update Metadata example

To update the metadata of your app, run the Update Metadata API or Update Metadata Slot API with a JSON like the following in the request body. Note that it should include all metadata in your app or slot, not just the ones you want to update.

    {
        "properties": {
            "author": "cephalin",
            "license": "MIT"
        }
    }

Update Diagnostic Logs Config example

To tun on application error logging, run the Update Diagnostic Logs Config API or Update Diagnostic Logs Config Slot API with a JSON like the following in the request body.

    {
        "properties": {
            "applicationLogs": {
                "fileSystem": {
                    "level": "Error"
                }
            }
        }
    }

Create Or Update Vnet Connection Gateway example

To add a update a Virtual Network gateway, run one of the following APIs:

with the a JSON like the following in the request body:

    {
        "properties": {
            "vnetName": "{vnetName}"
        }
    }

Create Or Update Vnet Connection example

To add or update a Virtual Network connection, run one of the following APIs

with a JSON like the following in the request body:

    {
        "properties": {
            "vnetResourceId": "/subscriptions/{subscription-Id}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}"
        }
    }

Swap Slot example

To swap a "staging" slot into the production slot, run the Swap Slot Slot API with a JSON like the following in the request body to specify the production slot as the target slot.

    {
        "targetSlot":"production"
    }

Get Slots Differences example

To compare a "staging" slot with the production slot, run the List Slots Differences Slot API with a JSON like the following in the request body to specify the production slot as the target slot.

    {
        "targetSlot":"production"
    }

Apply Slot Configuration example

To apply configuration settings from the production slot to a "staging" slot, run the Apply Slot Configuration Slot API with a JSON like the following in the request body to specify the production slot as the target slot.

    {
        "targetSlot":"production"
    }
</code>
</example>
        public HttpResponseMessage ApplySlotConfiguration()

Update Slot Configuration Names example

To specify a sticky "env" app setting for your app, run the Update Slot Configuration Names API with a JSON similar to the following in the request body. Note that it should include all sticky connection strings and app settings, not just the ones you want to update. To get a list of all existing sticky settings, run the List Slot Configuration Names API.

    {
        "properties": {
            "connectionStringNames": [],
            "appSettingNames": [
                "env"
            ]
        }
    }