I am trying to get a list of my current sites/slot app config and then combining it with a union so I don't overwrite the current deployed configuration. I am able to do this with the sites config but cannot with the deploy slot.
Here is an example of my working web sites in main.bicep
resource sites_web_name 'Microsoft.Web/sites@2021-02-01' = {
parameters here(irrelevant for excercise)
}
module web_appsettings_config './appsettings.bicep' = {
name: 'webAppSettings'
params: {
//this gets a list of the current app settings for the web site resource
currentAppSettings: list('${sites_web_name.id}/config/appsettings', '2021-02-01').properties
appSettings: {
'Config1': 'confighere'
'Config2': 'config2here'
'Config3': 'config3here'
}
name: '${sites_web_name.name}/appsettings'
}
}
appsettings.bicep
param currentAppSettings object
param appSettings object
param name string
resource siteConfig 'Microsoft.Web/sites/config@2021-02-01' = {
name: name
properties: union(currentAppSettings, appSettings)
}
The above is taking the current app settings deployed, not deleting/overwriting them if the new ones aren't specified in the template.
Now the problem trying to get sites/slot
main.bicep
resource sites_web_slots_name 'Microsoft.Web/sites/slots@2021-02-01' = {
parameters here(irrelevant for excercise)
}
module web_staging_appsettings_config './slotappsettings.bicep' = {
name: 'webStagingAppSettings'
params: {
//this gets a list of the current app settings for the web slot resource
currentAppSettings: list('${sites_web_slots_name.id}/slots/config/appsettings', '2021-02-01').properties
appSettings: {
'Config1': 'confighere'
'Config2': 'config2here'
'Config3': 'config3here'
}
name: '${sites_web_slots_name.name}/appsettings'
}
}
even made a separate module, slotappsettings.bicep
param currentAppSettings object
param appSettings object
param name string
resource siteSlotConfig 'Microsoft.Web/sites/slots/config@2021-02-01' = {
name: name
properties: union(currentAppSettings, appSettings)
}
The error I am getting for the slots failure is not helpful at all:
ERROR: {"status":"Failed","error":{"code":"DeploymentFailed","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.","details":[{"code":"NotFound","message":"{\r\n "error": {\r\n "code": "InvalidResourceNamespace",\r\n "message": "The resource namespace 'subscriptions' is invalid."\r\n }\r\n}"}]}}
I also don't get any deployment failure messages in the azure portal. Here is the documentation for the api versions I'm using:
sites/config/appsettings:
resource symbolicname 'Microsoft.Web/sites/config@2021-02-01' = {
name: 'appsettings'
kind: 'string'
parent: resourceSymbolicName
properties: {}
}
sites/slots/config/appsettings:
sites/slots/config-appsettings
resource symbolicname 'Microsoft.Web/sites/slots/config@2021-02-01' = {
name: 'appsettings'
kind: 'string'
parent: resourceSymbolicName
properties: {}
}
CodePudding user response:
There is a typo while calling the list
function for the slot settings:
You have /slots/config/appsettings
but it should only be /config/appsettings
because the /slots
segment is already included in the resource id of the slot (sites_web_slots_name.id
)