Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.26k stars 3.86k forks source link

Unable to retrieve AppSettings for a website (webapp) using Invoke-AzureResourceAction #541

Closed mcrsw closed 8 years ago

mcrsw commented 9 years ago

This code is a repo for the issue:

# NOTE: for the "HelperFunctions.ps1", please see David Ebbo's helper ps1 file:
# https://github.com/davidebbo/AzureWebsitesSamples/blob/master/PowerShell/HelperFunctions.ps1
# E.g. save this file, *and* the HelperFunctions.ps1 file to your C:\ drive
#
. "C:\HelperFunctions.ps1"

$ErrorActionPreference = "Stop"

$ResourceGroupName = "TestRG"
$Location = "North Europe"
$SiteName = "PSTest8000"
$PlanName = "MyPlan"

Write-Host "Creating Resource Group"
New-AzureResourceGroup -Name $ResourceGroupName -Location $Location -Force

Write-Host "Creating App Service Plan"
CreateAppServicePlan $ResourceGroupName $Location $PlanName

Write-Host "Creating Web App"
CreateWebApp $ResourceGroupName $Location $SiteName $PlanName

Write-Host "Getting Web App's AppSettings"
GetWebAppAppSettings $ResourceGroupName $SiteName

# This returns nothing (as expected)
Write-Host "Setting Web App's AppSettings"
SetWebAppAppSettings $ResourceGroupName $SiteName @{ "MyKeyOne" = "SomeValue"; "MyKeyTwo" = "OtherValue"; }

# Confirmed via NEW portal - these app settings are present

# Turn on debug trace:
$DebugPreference="Continue"

# This returns nothing (it should return the MyKeyOne and MyKeyTwo appsettings, as created above)
# This helper function does:
#    $res = Invoke-AzureResourceAction -ResourceGroupName $ResourceGroupName -ResourceType Microsoft.Web/sites/Config -Name $SiteName/appsettings -Action list -ApiVersion 2015-06-01 -Force
#    $res.Properties
#
Write-Host "Getting Web App's AppSettings (after setting)"
GetWebAppAppSettings $ResourceGroupName $SiteName

I have included (please see below) the debug trace output obtained from the final call to GetWebAppAppSettings. As you can see, the AppSettings ("properties") are actually returned in the HTTP response, yet they're not returned by the GetWebAppAppSettings (Invoke-AzureResourceAction) call itself.

Could this be an issue with the JSON deserialisation?

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

HTTP Method:
POST

Absolute Uri:
https://management.azure.com/subscriptions/{removed-this-sensitive-info}
/resourceGroups/TestRG/providers/Microsoft.Web/sites/PSTest8000/Config/appsetti
ngs/list?api-version=2015-06-01

Headers:
User-Agent                    : AzurePowershell/v0.9.3

Body:

DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
OK

Headers:
Pragma                        : no-cache
Strict-Transport-Security     : max-age=31536000; includeSubDomains
x-ms-request-id               : a5233e59-3c0b-41ba-905a-9b9a9b424456
x-ms-ratelimit-remaining-subscription-resource-requests: 11993
x-ms-correlation-request-id   : f73d2e18-ea79-4806-8b3d-5194b0506a1b
x-ms-routing-request-id       :
WESTEUROPE:{removed-this-sensitive-info}
Cache-Control                 : no-cache
Date                          : Thu, 25 Jun 2015 10:21:46 GMT
Server                        : Microsoft-IIS/8.0
X-AspNet-Version              : 4.0.30319
X-Powered-By                  : ASP.NET

Body:
{
  "id":
"/subscriptions/{removed-this-sensitive-info}/resourceGroups/TestRG/prov
iders/Microsoft.Web/sites/PSTest8000/config/appsettings",
  "name": "appsettings",
  "type": "Microsoft.Web/sites/config",
  "kind": null,
  "location": "North Europe",
  "tags": null,
  "plan": null,
  "properties": {
    "MyKeyTwo": "OtherValue",
    "MyKeyOne": "SomeValue"
  }
}
markcowl commented 9 years ago

@mcrsw thans for the report, routing to the service team to investigate.

ravbhatnagar commented 8 years ago

Fixed in the latest PS release.

ghost commented 5 years ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @rthorn17