Skip to content

az webapp and unexpected results when defining slot via id instead of param #26334

@frankvaneykelen-work

Description

@frankvaneykelen-work

One of our teams used this command to set app settings on the staging slot:

az webapp config appsettings set `
    --ids /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/foo-rg/providers/Microsoft.Web/sites/foo-app/slots/staging `
    --settings expectedslot=staging actualslot=production

They expected this command to add the settings to the staging slot (as set via the --ids param), but instead they were added to the production slot. This let me to search for a command that could be parameterized to work both for test environments (that directly deploy to the production slot) and production (that deploys to a staging slot), but I came back empty handed.

This what I would like to do:

$slotName = "staging"
az webapp config appsettings set `
    --ids /subscriptions/[...]/resourceGroups/foo-rg/providers/Microsoft.Web/sites/foo-app `
    --slot $slotName  --settings [...]

# same command with different parameter value
$slotName = "production"
az webapp config appsettings set `
    --ids /subscriptions/[...]/resourceGroups/foo-rg/providers/Microsoft.Web/sites/foo-app `
    --slot $slotName  --settings [...]

The first command succeeds, but the last command fails with:

(ResourceNotFound) The Resource 'Microsoft.Web/sites/foo-app/slots/production' under resource group 'foo-rg' was not found. 
For more details please go to https://aka.ms/ARMResourceNotFoundFix

An alternative way via the --ids instead of the --slot also doesn't work:

$slotName = "staging"
az webapp config appsettings set `
    --ids /subscriptions/[...]/resourceGroups/foo-rg/providers/Microsoft.Web/sites/foo-app/slots/$slotName`
    --settings [...]

# same command with different slot in ids paramater value
$slotName = "production"
az webapp config appsettings set `
    --ids /subscriptions/[...]/resourceGroups/foo-rg/providers/Microsoft.Web/sites/foo-app/slots/$slotName`
    --slot $slotName  --settings [...]

Both commands succeed, but the first applies the appsettings to the production slot while $slotName = "staging"!

It tested the az webapp show and az webapp config appsettings set methods in the Azure Cloud Shell with all possible combinations and here are the results:

az webapp show inconsistencies

nr slot in id slot as param result as expected?
01 x x returns production yes
02 x production ResourceNotFound no (expected production)
03 x staging returns staging yes
04 production x returns production yes
05 production production ResourceNotFound no (expected production)
06 production staging returns staging no (expected conflict error)
07 staging x returns production no (expected staging)
08 staging production ResourceNotFound no (expected conflict error)
09 staging staging returns staging yes

az webapp config appsettings set inconsistencies

slot in id slot as param result as expected?
10 x x adds to production slot yes
11 x production ResourceNotFound no (expected production)
12 x staging adds to staging slot yes
13 production x adds to production slot yes
14 production production ResourceNotFound no (expected production)
15 production staging adds to staging slot no (expected conflict error)
16 staging x adds to production (!) slot no (expected staging)
17 staging production ResourceNotFound yes
18 staging staging adds to staging slot yes

I would like it if # 02 and # 11 would be fixed so that passing 'production' as a --slot param without a slot in de --ids would find the 'production' slot.

The other inconsistencies are harder to fix without introducing breaking changes.

Or am I missing something, and is this as intended?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions