In order to make life easier, you might want to consider to have a predefined Host Key for your Azure Function Apps in your development/test environment. This can enable you to run (automated) tests without needing to find/update the host key after every new deployment.
Disclaimer: Setting a predefined Host Key to your Azure Function App (even if it’s “SuperDuperSecret1!”) is a serious security hazard and should not be applied to any production environment!
Bash
Below script is an adaptation of this script on Github.
PowerShell
If PowerShell has your preference, you can use below block. A service principal is used to login due to it being used in a Azure DevOps deployment pipeline. If you’re running this from an environment where you’re already logged on, you can remove that part.
Thanks/Acknowledgements
Thanks to:
- @AzureSupport for pointing me in the right direction
- This blog post from Mark Heath on calling the Key management API using PowerShell
- This Github Gist containing a bash script to retrieve the Host key