首页 > 解决方案 > API 调用在 powershell Azure Functions 中不起作用

问题描述

我正在尝试在 Azure 函数中使用 powershell 运行一个简单的 API 调用

 $Headers = @{ 
   "Accept" = "*/*" 
   "Authorization" = "Bearer "+ $Token 
   "accept-encoding" = "gzip" 
   "content-type"="application/json" 
   "content-length" = "2" 
} 

 $uri = "https://www.example.com/api/vl/$test

 $response = Invoke-WebRequest -Uri $uri -Method Delete -Headers $Headers 

 Write-Host $response.Content

上述命令在我的 PC 上使用 powershell 工作,删除请求已执行。但是在 Azure 函数中,它有以下错误:

 Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host

我花了很多时间来解决这个问题,根据我的在线研究,我尝试允许 TLS1.0 和 http;在应用服务编辑器中增加 host.json 文件中的函数超时;并设置 PSWorkerInProcConcurrencyUpperBound = 1。但它们都不起作用。知道这里有什么问题吗?

我对 Azure Function 和 Powershell 非常陌生,因此非常感谢任何帮助。

标签: azurepowershellapiazure-functionstls1.2

解决方案


推荐阅读