用于容器的 Azure Web 应用程序 - 容器无法连接到外部 WCF 服务

时间:2021-05-14 03:21:43

标签: azure docker azure-web-app-service containers azure-web-app-for-containers

我有一个 Windows 容器作为 Azure Web 应用程序,它连接到容器外的 WCF 服务,当我在本地测试容器的功能时,它可以工作,但不能在 Azure 中工作。

我的应用程序在容器内有一个日志文件。它说: 无法解析远程名称:'XXXXXX.azurewebsites.net' <- 这是 WCF 服务

我试过了:

  • 将 DNS 8.8.8.8 设置为 azure 上的应用程序设置 [无变化]
  • Ping google.com [失败]

有什么想法吗?

感谢您的帮助!

1 个答案:

答案 0 :(得分:1)

要在 Windows 容器应用中设置公共 DNS 服务器,您可以运行以下命令:

$nic = Get-NetAdapter
Set-DnsClientServerAddress -InterfaceIndex $nic.IfIndex -ServerAddresses ('8.8.8.8')

enter image description here

有关详细信息,您可以阅读Private DNS for Native Windows Docker Container