无法访问Azure Functions的管理URL [英] Unable to access admin URL of Azure Functions

查看:124
本文介绍了无法访问Azure Functions的管理URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Powershell,并尝试使用api访问Azure功能管理
我试图获取在$ appName下创建的所有函数的列表

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

当然,我在调用前用实际的Azure函数名称更改了$ appName

Certainly i am changing $appName with actual Azure Function name before call

在此调用之前,我也获得了有效的$ authToken。

I also got valid $authToken before this call.

以下URL:

$Functions = Invoke-RestMethod -Method GET -Headers @{Authorization = ("Bearer {0}" -f $authToken)} -Uri "https://$appName.azurewebsites.net/admin/functions"

和我的Powershell中的错误执行是:

and the error in my powershell execution is :

Invoke-RestMethod:

Invoke-RestMethod :

The underlying connection was closed: An unexpected error occurred on a send.
At KeyFA.ps1:36 char:18
+ ... Functions = Invoke-RestMethod -Method GET -Headers @{Authorization =  ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

我尝试将其设置为POST而不是GET,但存在相同错误。

I tried make it POST instead of GET but same error.

我尝试访问浏览器中的这个网址,浏览器中的错误是:

I tried access this url in broswer and the error in my broswer is :

http 401表示未授权。

http 401 means unauthorized.

然后我也尝试从邮递员访问此URL,并正确设置了Bearer身份验证,但出现以下错误:

Then i also tried access this URL from postman with Bearer auth correctly set but get below errors:

Could not get any response
There was an error connecting to 
https://appname_comes_here.azurewebsites.net/admin/functions/

什么是我的操作不正确?

What am i not doing correctly?

无法修复此错误。 URL现在是否已被Azure功能站点终止?

Not able to fix this error. Is the url discontinued by Azure function site now?

推荐答案

由于您只发布了部分PowerShell代码,因此错误信息似乎是网络问题,我不知道

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.

所以我只是在这里发布工作PowerShell脚本,您可以参考我的代码来解决您的问题。 / p>

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"

注意:您可以按照下图获取 $ userName $ userPWD 值。

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

图1.在Azure门户上,打开Function App的 Platform features 选项卡,然后单击部署中心链接

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

图2.在 SOURCE CONTROL 的第一步中,选择 FTP 选项c $ c>,然后单击仪表板按钮以复制用户名密码,但只需将用户名的一部分与 $ 前缀一起用作 $ userName 在我的脚本中

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

这篇关于无法访问Azure Functions的管理URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆