4

I need to get a key to access code for HttpTrigger https://mydomain.azurewebsites.net/api/registration?code=Key. In Azure function 1x, with Url https://$functionAppName.scm.azurewebsites.net/api/functions/admin/masterkey will return my master key like {"masterKey":"ehp9f***************************"} but, in Azure Function 2x this way isn't work. How can I connect HttpTrigger in PowerShell with Azure Function 2x. Another SCM Api or syntax instead of (Invoke-RestMethod -Uri https://mydomain.scm.azurewebsites.net/api/functions/admin/masterkey -Headers @{"Authorization"=$accessToken;"If-Match"="*"} ).Masterkey in Azure function 1x.

Thanks for your support

Hung Nguyen Duy
  • 165
  • 1
  • 9

3 Answers3

1

This is a known issue check this wiki doc:ARM Impact and this issue:listSecrets broken for function keys in V2.

For now there is a new api however it's not released you could check this issue:Expand/Improve Functions ARM APIs.

Here is a sample api:

POST api/sites/{name}[/slots/{slot}]/host/default/listkeys

{
"masterKey": "<keyvalue>",
"functionKeys": {
  "default": "<keyvalue>",
  "my-key": "<keyvalue>"
},
"systemKeys": {
  "test-system": "<keyvalue>",
  "my-key": "<keyvalue>"
}
}
George Chen
  • 13,703
  • 2
  • 11
  • 26
1

For those who cannot find the _master key as described in this article Get the function's master key, go the the root of the function resource and look in the App keys tab.

Stephane
  • 11,056
  • 9
  • 41
  • 51
0

Navigate to your function in the Azure portal and click on Manage and find the Host Keys section. Click on the Copy button in the _master row to copy the master key to your clipboard.

Source: Get the function's master key

If you need to retrieve the master key inside an ARM template, take a look at the listkeys function.

Martin Brandl
  • 56,134
  • 13
  • 133
  • 172
  • sorry, my mistake with my question I want to use PowerShell to get a master key, In Azure Function 1x with syntax $masterKey = (Invoke-RestMethod -Uri https://mydomain.scm.azurewebsites.net/api/functions/admin/masterkey -Headers @{"Authorization"=$accessToken;"If-Match"="*"} ).Masterkey. And I detect 'https://mydomain.scm.azurewebsites.net/api/functions/admin/masterkey' is not work in 2x so, I want no find some 'scm api' to instead It – Hung Nguyen Duy Oct 30 '19 at 09:40