azure-powershell icon indicating copy to clipboard operation
azure-powershell copied to clipboard

Set-AzWebApp and Set-AzWebAppSlot removing tags when passing the WebApp JSON as an input

Open vinhent opened this issue 7 years ago • 5 comments

Description

Tags are being removed when calling Set-AzWebApp or Set-AzWebAppSlot.

By reading the release notes it looks like it should've been fixed in module Az version 1.8.0.

Release Notes 1.8.0 - April 2019 ... Az.Websites

  • fixes the Set-AzWebApp and Set-AzWebAppSlot to not remove the tags on execution

There are multiple REST API calls made in Set-AzWebApp, but it seems to be at the step of this one that the tags are being removed:

PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}

Steps to reproduce

$resourceGroupName = "myresourcegroup"
$appName = "mywebappname"

$webApp = Get-AzWebApp -ResourceGroupName $resourceGroupName -Name $appName -ErrorAction Stop
$webApp.Tags # My actual tags are returned.

# Changing a setting on my web app
$webApp.SiteConfig.Use32BitWorkerProcess = $false

# Saving the new configuration
$webApp = Set-AzWebApp -WebApp $webApp -ErrorAction Stop
$webApp.Tags # This is now null and tags are gone.

Environment data

Name                           Value
----                           -----
PSVersion                      5.1.17134.590
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17134.590
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Module versions

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.5.2      Az.Accounts                         {Add-AzEnvironment, Clear-AzContext, Clear-AzDefault, Connect-AzAccount...}
Script     1.2.1      Az.Websites                         {Edit-AzWebAppBackupConfiguration, Enter-AzWebAppContainerPSSession, Get-A...

Debug output

DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
PUT

Absolute Uri:
https://management.azure.com/subscriptions/xxx-xxx-xxx-xxx-xxxxxxx/resourceGroups/xxxx/providers/Microsoft.Web/sites/testwebapptags?api-version=2018-02-01

Headers:
x-ms-client-request-id        : 0dd5f017-e9e9-42f3-983c-a9ddf97aeb6f
accept-language               : en-US

Body:
{
  "properties": {
    "serverFarmId": "testplan"
  },
  "location": "Canada East"
}
DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
OK

Headers:
Pragma                        : no-cache
Strict-Transport-Security     : max-age=31536000; includeSubDomains
x-ms-request-id               : 6105a6fb-1996-42ee-bf19-7671d98b4557
x-ms-ratelimit-remaining-subscription-resource-requests: 499
x-ms-correlation-request-id   : 288fa445-70c4-4aa3-a902-c13f695a51ea
x-ms-routing-request-id       : NORTHCENTRALUS:20190509T005139Z:288fa445-70c4-4aa3-a902-c13f695a51ea
X-Content-Type-Options        : nosniff
Cache-Control                 : no-cache
Date                          : Thu, 09 May 2019 00:51:39 GMT
ETag                          : "1D506015B7F48E0"
Server                        : Microsoft-IIS/10.0
X-AspNet-Version              : 4.0.30319
X-Powered-By                  : ASP.NET

Body:
{
  "id": "/subscriptions/xxx-xxx-xxx-xxx-xxxxxxx/resourceGroups/xxxx/providers/Microsoft.Web/sites/testwebapptags",
  "name": "testwebapptags",
  "type": "Microsoft.Web/sites",
  "kind": "app",
  "location": "Canada East",
  "properties": {
    "name": "testwebapptags",
    "state": "Running",
    "hostNames": [
      "testwebapptags.azurewebsites.net"
    ],
    "webSpace": "xxxx-CanadaEastwebspace",
    "selfLink": "https://waws-prod-yq1-009.api.azurewebsites.windows.net:454/subscriptions/xxx-xxx-xxx-xxx-xxxxxxx/webspaces/xxxx-CanadaEastwebspace/sites/testwebapptags",
    "repositorySiteName": "testwebapptags",
    "owner": null,
    "usageState": "Normal",
    "enabled": true,
    "adminEnabled": true,
    "enabledHostNames": [
      "testwebapptags.azurewebsites.net",
      "testwebapptags.scm.azurewebsites.net"
    ],
    "siteProperties": {
      "metadata": null,
      "properties": [
        {
          "name": "LinuxFxVersion",
          "value": ""
        },
        {
          "name": "WindowsFxVersion",
          "value": null
        }
      ],
      "appSettings": null
    },
    "availabilityState": "Normal",
    "sslCertificates": null,
    "csrs": [],
    "cers": null,
    "siteMode": null,
    "hostNameSslStates": [
      {
        "name": "testwebapptags.azurewebsites.net",
        "sslState": "Disabled",
        "ipBasedSslResult": null,
        "virtualIP": null,
        "thumbprint": null,
        "toUpdate": null,
        "toUpdateIpBasedSsl": null,
        "ipBasedSslState": "NotConfigured",
        "hostType": "Standard"
      },
      {
        "name": "testwebapptags.scm.azurewebsites.net",
        "sslState": "Disabled",
        "ipBasedSslResult": null,
        "virtualIP": null,
        "thumbprint": null,
        "toUpdate": null,
        "toUpdateIpBasedSsl": null,
        "ipBasedSslState": "NotConfigured",
        "hostType": "Repository"
      }
    ],
    "computeMode": null,
    "serverFarm": null,
    "serverFarmId": "/subscriptions/xxx-xxx-xxx-xxx-xxxxxxx/resourceGroups/xxxx/providers/Microsoft.Web/serverfarms/testplan",
    "reserved": false,
    "isXenon": false,
    "hyperV": false,
    "lastModifiedTimeUtc": "2019-05-09T00:51:38.98",
    "storageRecoveryDefaultState": "Running",
    "contentAvailabilityState": "Normal",
    "runtimeAvailabilityState": "Normal",
    "siteConfig": null,
    "deploymentId": "testwebapptags",
    "trafficManagerHostNames": null,
    "sku": "Basic",
    "scmSiteAlsoStopped": false,
    "targetSwapSlot": null,
    "hostingEnvironment": null,
    "hostingEnvironmentProfile": null,
    "clientAffinityEnabled": true,
    "clientCertEnabled": false,
    "clientCertExclusionPaths": null,
    "hostNamesDisabled": false,
    "domainVerificationIdentifiers": null,
    "kind": "app",
    "outboundIpAddresses": "40.86.225.89,40.86.226.148,40.86.227.81,40.86.225.159,40.86.226.43",
    "possibleOutboundIpAddresses": "40.86.225.89,40.86.226.148,40.86.227.81,40.86.225.159,40.86.226.43,40.86.227.75,40.86.231.40,40.86.225.81",
    "containerSize": 0,
    "dailyMemoryTimeQuota": 0,
    "suspendedTill": null,
    "siteDisabledReason": 0,
    "functionExecutionUnitsCache": null,
    "maxNumberOfWorkers": null,
    "homeStamp": "waws-prod-yq1-009",
    "cloningInfo": null,
    "hostingEnvironmentId": null,
    "tags": null,
    "resourceGroup": "xxxx",
    "defaultHostName": "testwebapptags.azurewebsites.net",
    "slotSwapStatus": null,
    "httpsOnly": false,
    "redundancyMode": "None",
    "inProgressOperationId": null,
    "geoDistributions": null
  }
}

Error output


vinhent avatar May 09 '19 01:05 vinhent

@panchagnula Please take a look

markcowl avatar May 10 '19 22:05 markcowl

@vinhent can you try with the latest version the changes the fix for this was in version https://github.com/Azure/azure-powershell/releases/tag/v1.8.0-April2019

panchagnula avatar May 13 '19 20:05 panchagnula

@vinhent actually for what you are trying to update please use the command as follows

Set-AzWebApp -ResourceGroupName $rgname -Name $appname -Use32BitWorkerProcess $true

panchagnula avatar May 13 '19 22:05 panchagnula

Hi,

Thanks for the help.

I'm using Az version 2.0.0 and still have the same issue.

For now my workaround is to set the tags again with "Set-AzResource -Tag $tags" after they are removed by "Set-AzWebApp".

vinhent avatar May 14 '19 13:05 vinhent

Hi,

Thanks for the help.

I'm using Az version 2.0.0 and still have the same issue.

For now my workaround is to set the tags again with "Set-AzResource -Tag $tags" after they are removed by "Set-AzWebApp".

Use the Set-WebApp with out the -WebApp argument like this & that will work Set-AzWebApp -ResourceGroupName $rgname -Name $appname -Use32BitWorkerProcess $true I have a PR out with the fix when using -WebApp as well

panchagnula avatar May 14 '19 15:05 panchagnula