【问题标题】:Azure Function Key Management API - Authentication errorAzure 功能密钥管理 API - 身份验证错误
【发布时间】:2019-01-31 16:13:59
【问题描述】:

我有两个 Azure 函数应用,都在同一个 Azure 订阅中。我可以检索其中一个的密钥,但不能检索另一个。据我所知,这两个功能应用程序之间没有区别。

我正在使用这个 Powershell 代码:

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
}

对 $siteBaseUrl/admin/host/systemkeys/_master 的调用返回一个函数应用的预期 json,但另一个返回登录屏幕。

【问题讨论】:

标签: azure authentication azure-active-directory azure-functions


【解决方案1】:

比较两个功能设置、版本。尝试从门户手动获取密钥以隔离问题的根源。在我删除并重新创建函数之前,我遇到了同样的问题。

【讨论】:

    猜你喜欢
    • 2020-06-05
    • 2021-01-18
    • 2021-11-16
    • 2023-04-01
    • 1970-01-01
    • 2018-06-21
    • 2016-08-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多