[Question] Functions 'Host Keys' & ARM templates
Hi,
We utilize the Host Keys to protect functions. I know on the portal it is possible to add a custom host key, meaning that if they were behind a traffic manager, the codes could be the same - for example.
Is there any way that we can do any of the following (in order of preference..):
-
- Set host keys with an ARM template?
-
- Set host keys with an api call?
-
- (but last resort..) Retrieve host keys (either on ARM or an api call? - not important if we can set them though).
Thanks,
I am facing the exact same issue. What options are available?
If using function key rather than host key is an option, you can easily retrieve them programmatically within your ARM template with the listsecrets method. more info here
The issue is that I need to set a key on both function applications that is shared(the same value) because there are multiple instances of the function app behind a load balancer.
Same. I've tweaked the question so the options are a little clearer in a preferred order to solve this issue.
@Mandur thanks for that - unfortunately if it requires the function name it wouldn't work for us, hence the host keys.... but it's a nice solution. If I have some time I'll dig around from that point on the ARM templates to see if I can get the host keys out via arm.
Reading the host keys though is a last resort and is only possible for us because of the specific way our platform is set up... hence setting the keys is still going to be needed in some way...
I'm running into similar issue. I am deploying my Azure Functions using ARM Templates (the shell) and then the actual Function code using MSDeploy. Unfortunately, there is a chicken & egg situation. When deploying the ARM templates, no functions exist, so I can't set or obtain any function level keys. This is where a host key could come into play. Similar to the original poster, it would be nice to be able to add additional keys since they are always auto generated when creating the function shell or function itself. We have multiple systems that call these Functions, and I've setup Function Keys for each one, and then shared to these systems. If I need to recreate the envrionments, I can automate the deploy of shell & code, but need to manually go into the Portal to set the keys back to what they were.
Another option would be when deploying the Azure Function code itself using MSDeploy, being able to specify additional Function level keys in the function.json or something that is deployed and read by the runtime.
Last restore would be setting up some post deploy powershell and manually create the known/shared keys via the REST API.
Please visit this blog : http://bloggingoncloud.com/get-azure-function-app-master-key-host-key-by-api-end-point-programmatically/
information mentioned might be useful to get the keys over API calls and ARM client / Powershell
Are there any plans to provide access via ARM to the host-level keys?
I'm about to add a custom Powershell step to my deploy process, but it would be nice to avoid :)
I would like to request this feature be added to azure cli. thanks! i can't automate my environment(load balanced function apps with trafficmanager) at the moment.
any option via ARM template? Also how to create function key? Since code is deployed via web deploy, should we write custom powershell to create function key?
Is the ability to provision function app host keys (and individual function keys if possible, given function names in advance) via ARM on the roadmap. @jeffhollan
Just pulling apart thread (and adding @fabiocav as we were discussing keys + ARM the other day). Is the ask you want to SET a host key as part of an ARM template? I can't say it's something that is being tracked / high on backlog but if so let me know and we can track the ask. Understand the desire here to have consistent host keys across apps as well.
Yep, exactly, function keys as well, although I am not sure that is doable at ARM time, since function names aren't even know yet. Our app has multiple instances of identical function apps scattered across Azure regions, think webhook subscriber. If webhook provider sends webhook from different geo closer to a different region, it needs to be the same host key. This is "our" scenario, we only want 1 webhook url for subscriptions, in our case routed through Traffic Manager.
Hi @jeffhollan. My desire is just to be able to access the host key as part of the ARM template via a listsecrets call. Thanks!
Hi guys, just would like to ask if it's available now to get host keys for a function app in ARM? I did some research and found in ARM, it only supports to get function key, not host key yet. Is it still so, or we have any plan to get it available in some future release?
Listing the host key with listsecrets in an ARM template is a pretty important feature that is missing. I can retrieve the function keys individually but this is not ideal for a number of reasons. First, the ARM template needs to be updated every time a function is added. More importantly, the listsecrets will fail until we deploy our functions, so the ARM template will fail the first time we run it.
Its almost a year... I am curious how do you deploy Api Management policies when Azure function require host keys?
Being able to get host keys is very important to us as well.
Clarifying and also updating:
- You can get a function key in ARM templates today when targeting the v1 runtime. This is possible through the listSecrets expression for the function
- We do have gaps for getting secrets with ARM alone in the v2 runtime (and in the v1 runtime).
- We are aware of the gaps and have work planned for this calendar year to surface a much better key management surface that should be ARM compatible. I can't comment specifically on the date but this is one of the highest items on our backlog right now to tackle after v2 GA
Definitely tracking the following scenarios:
- Ability to get a function key so you can have a function URL as an output of an ARM deploy
- Ability to get an Event Grid or other webhook key so you can use it in an ARM template
Not sure I understand the scenario where you want the HOST key, but let me know so I can make sure we are tracking.
I eventually found the syntax for retrieving the host key in an ARM template from someone's blog. There seem to be plenty of other people that have trouble finding it. Some better documentation that is straightforward to find would help a lot.