azure - 托管 .NET Core 5 应用程序的 Azure Windows AppService 无法使用 Invoke-Command(“在计算机上找不到服务 WinRM”)
问题描述
我将 .NET Core 5 应用程序部署到 Azure 中的本机 Windows AppSerice。在应用程序内部我运行 Powershell 命令:
Invoke-Command -Computer '{endpoint}' -Scriptblock {{{scriptBody}}} -Credential $credential
endpoint
我想在其上运行脚本的运行 Windows 的 Azure VM 的私有 IP 地址在哪里。
AppService 已使用 VNet 集成功能添加到与 Azure VM 相同的 Vnet 中,因此两个“机器”都可以相互访问。
执行时Invoke-Command
我得到:
An error has occurred which PowerShell cannot handle. A remote session might have ended.
然后我尝试了Enable-PSRemoting
,但我得到了:
Access is denied. To run this cmdlet, start PowerShell with the "Run as administrator" option
- 这是可以理解的。我不希望 AppSerice 允许运行管理 cmdlet。
我也试过了Set-Item WSMan:\\localhost\\Client\\TrustedHosts -Value 'endpoint'"
,我得到:
Service WinRM was not found on computer '.'
WinRm 服务不适用于 Native Windows AppService?这意味着我根本无法使用 AppService 中的远程 Powershell 功能?或者我需要在 Azure 门户中以某种方式安装或启用它?
PS。我尝试从“VM 到 VM”(不是 AppService 到 VM)运行完全相同的Invoke-Command
操作,然后它运行良好,以便执行脚本(尽管我需要将 IP 添加到 TrustedHosts)。
解决方案
推荐阅读
- node.js - 在另一个模块中定义 EventEmitter 处理程序而不导出功能
- php - 添加域时,我无法在项目中注册/添加新用户,但它正在本地主机上运行
- angular - 订阅 LoggedIn Observable 不起作用
- java - 如何总结反射数和原始数?
- allennlp - Allennlp 命令或 token_embedders 中没有 Fine-Tune/ Bert_token_embedder 模块
- javascript - Chrome 的“Aw,Snap!错误代码:11”指的是什么?
- snowflake-cloud-data-platform - Snowflake 是否监控“Snowflake Ideas Pages”并采取行动?
- php - 有没有办法根据数据库中的数据只执行 WHERE 语句的一部分?
- c - 从子进程获取退出代码
- python - Colab 没有使用 GPU 进行训练