0

I have two Azure function apps, both in the same Azure subscription. I can retrieve keys for one but not for the other. As far as I can see there is no difference between the two function apps.

I'm using this Powershell code:

function GetHostKey
{
    param($webAppName, $resourceGroupName)

    [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

    Write-Host "Getting master key from $webAppName"

    $xml = [xml](Get-AzureRmWebAppPublishingProfile -Name $webAppName -ResourceGroupName $resourceGroupName -Format WebDeploy -OutputFile null)
    $msdeployUsername = $xml.SelectNodes("//publishProfile[@publishMethod=`"MSDeploy`"]/@userName").value
    $msdeployPassword = $xml.SelectNodes("//publishProfile[@publishMethod=`"MSDeploy`"]/@userPWD").value

    $apiBaseUrl = "https://$webAppName.scm.azurewebsites.net/api"
    $siteBaseUrl = "https://$webAppName.azurewebsites.net"

    $base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $msdeployUsername,$msdeployPassword)))
    $jwt = Invoke-RestMethod -Uri "$apiBaseUrl/functions/admin/token" -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -Method GET

    $uri = "$siteBaseUrl/admin/host/systemkeys/_master"
    $response = Invoke-RestMethod -Uri $uri -Headers @{Authorization=("Bearer {0}" -f $jwt)} -Method GET
    return $response.value
}

The call to $siteBaseUrl/admin/host/systemkeys/_master returns the expected json for one function app, but the other one returns a login screen.

3
  • You can try this code: stackoverflow.com/questions/46521356/… Commented Jan 31, 2019 at 16:22
  • Hi Anass, Thanks, but I get the same problem with your code too! Commented Jan 31, 2019 at 17:02
  • can you try getting default key instead of master Commented Jan 31, 2019 at 17:04

1 Answer 1

0

Compare both functions settings, versions. Try to get the keys manually from the portal to isolate the source of the problem. I had the same problem till i deleted and recreated the functions.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.