Unable to access admin URL of Azure Functions

前端 未结 1 803
南笙
南笙 2021-01-26 20:58

I am using powershell and trying to access Azure functions Administration using api. I am trying to get list of all functions created under $appName

Cer

相关标签:
1条回答
  • 2021-01-26 21:22

    Due to you just post the partial PowerShell code and the error information seems to be a network issue, I don't know what real issue you got is and how to fix it.

    So I just post my work PowerShell script at here, you can refer to my code to fix your issue.

    $appName = "<your app name>"
    $userName='<your app credential user name>'
    $userPWD='<your app credential user password>'
    
    $apiBaseUrl = "https://$($appName).scm.azurewebsites.net/api"
    $appBaseUrl = "https://$($appName).azurewebsites.net"
    
    $base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $userName,$userPWD)))
    
    $jwt = Invoke-RestMethod -Uri "$apiBaseUrl/functions/admin/token" -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -Method GET
    
    $Functions = Invoke-RestMethod -Method GET -Headers @{Authorization = ("Bearer {0}" -f $jwt)} -Uri "$appBaseUrl/admin/functions"
    

    Note: you can follow the figures below to get the $userName and $userPWD values.

    Fig 1. On Azure portal, open the Platform features tab of your Function App and click the Deployment Center link

    Fig 2. Select the FTP option in the first step of SOURCE CONTROL and click the Dashboard button to copy the values of Username and Password, but just use the part of Username with $ prefix as $userName in my script

    0 讨论(0)
提交回复
热议问题