I want to add a default function key to my deployment slot in azure. Therefore I've added it to my template like this:
...,
{
"type": "Microsoft.Web/sites/slots/functions/keys",
"dependsOn":[
"[resourceId('Microsoft.Web/sites/slots', variables('apiServiceName'),'deploy')]"
],
"apiVersion": "2018-02-01",
"name": "[concat(variables('apiServiceName'),'/deploy/default/eventgrid')]",
"properties": {
"name": "eventgrid"
}
},...
Unfortunately, I cannot find how to get it to work, this is the closest I can find to not have the template fail (fewer segments make the template invalid) Now I get this error:
NotFound: Error creating or updating function key.
The API docs explain how it works, and I think it matches what I have here for the ARM template, but I can't seem to figure out why I get a not found error... Anyone ever tried this for an azure function slot? I can get it to work for the production slot though:
...,
{
"type": "Microsoft.Web/sites/host/functionKeys",
"dependsOn":[
"[resourceId('Microsoft.Web/sites', variables('apiServiceName'))]"
],
"apiVersion": "2018-11-01",
"name": "[concat(variables('apiServiceName'), '/default/eventgrid')]",
"properties": {
"name": "event-grid"
}
},...
Any help is appreciated.
This worked for me. I think you're missing the slot name in the name property:
{
"type": "Microsoft.Web/sites/slots/host/functionKeys",
"apiVersion": "2018-11-01",
"name": "[concat(variables('functionAppName'), '/staging', '/default/key')]",
"properties": {
"name": "key",
"value": "[parameters('key')]"
},
"dependsOn": [
"[resourceId('Microsoft.Web/sites/slots', variables('functionAppName'), 'staging')]"
]
},