azure - Azure 应用服务的间歇性部署问题

标签 azure azure-devops azure-web-app-service

自 8 月 1 日以来,我们间歇性无法部署高级应用服务计划的任何更新。我们的主要部署方式是通过 Azure DevOps Pipelines(Microsoft 托管,而非自托管),这些管道已稳定运行数月甚至超过 1 年。在过去的几个月里,我们没有对管道或应用服务计划进行任何更改(除了 Microsoft 支持部门请求的更改之外)。

当这些间歇性问题发生时,我们部署更新的能力一次最多会受到影响,并且还会影响我们直接从 Visual Studio 2022 发布(作为部署的备份方式)的能力。此外,当发生这些部署问题时,托管的 Web 应用程序是可访问且响应迅速的,Kudu (SCM) 端点也是如此。

我们在管道日志中看到的错误如下(我们正在使用 AzureRmWebAppDeployment@4 任务):

Error: Error Code: ERROR_COULD_NOT_CONNECT_TO_REMOTESVC More Information: 
Could not connect to the remote computer ("XXXXX.scm.azurewebsites.net") using the specified process ("Web Management Service") because the server did not respond. 
Make sure that the process ("Web Management Service") is started on the remote computer. 
Learn more at: https://go.microsoft.com/fwlink/?LinkId=221672#ERROR_COULD_NOT_CONNECT_TO_REMOTESVC. 
Error: The remote server returned an error: (500) Internal Server Error. 
Error count: 1.

FWIW,我们的应用程序正在运行 ASP.NET 6。

我们尝试通过搜索堆栈溢出或 Microsoft 支持解决的问题包括:

  1. 作为 ZipDeploy 运行。
  2. 使用应用设置 WEBSITE_RUN_FROM_PACKAGE = 1 作为 ZipDeploy 运行。
  3. 添加应用设置 WEBSITE_WEBDEPLOY_USE_SCM = true。
  4. 通过 Visual Studio 的发布配置文件进行部署。
  5. 删除 Kudu 中的日志。
  6. 删除 Kudu 中的部署。
  7. 通过删除旧的内存转储来释放空间
    • 注意:Azure 报告我们使用了计划总存储空间的 4%。
  8. 重新启动应用服务/Kudu。
  9. 查看其他 stackoverflow 文章 https://stackoverflow.com/search?tab=newest&q=%5bazure-web-app-service%5d%20ERROR_COULD_NOT_CONNECT_TO_REMOTESVC&searchOn=3

我们一直在与 Microsoft 支持部门合作解决此问题,但他们的问题让我相信他们不了解我们正在使用应用服务计划来托管我们的应用程序(而不是自托管或使用虚拟机)。

最佳答案

  • 间歇性连接问题的原因之一是创建新的出站连接时达到限制。 TCP 连接和 SNAT 端口是您可能会遇到的一些限制。 请参阅此 MS documentation出站连接上的内容包括有关 SNAT 端口限制及其如何影响连接的信息。为了与公共(public) IP 地址进行连接,Azure 使用对客户隐藏的负载均衡器和源网络地址转换,或 SNAT。

  • 最初为每个 Azure 应用服务实例预先分配了 128 个 SNAT 端口。对相同地址和端口组合进行的连接受到 SNAT 端口限制的影响。如果您的应用程序与各种地址和端口组合建立连接,您的 SNAT 端口将不会耗尽。

  • 您可以使用几种不同的方法来绕过 SNAT 端口限制。它们由 NAT 网关、连接池、服务端点和专用端点组成。该问题最明显的解决方案之一是连接池。如果您的目标是支持服务终结点的 Azure 服务,则利用区域 VNet 集成、服务终结点或专用终结点将帮助您避免 SNAT 端口耗尽问题。

  • 如果您使用区域 VNet 集成并将服务端点放在集成子网上,您的应用到这些服务的出站流量将不会受到出站 SNAT 端口限制。同样,如果您使用区域 VNet 集成和专用端点,您将不会看到该位置的任何传出 SNAT 端口困难。

为了解决此问题,您需要访问诊断并解决问题

enter image description here

您还可以在其他部分检查与您的网络应用程序相关的问题并解决它,如下所示:-

enter image description here

我的 Azure Web 应用 DevOps 任务:-

trigger:
- master

variables:

  
  azureSubscription: 'xxxxx28-8xx6-xxx'

  
  webAppName: 'valleywebapp09'

  
  environmentName: 'valleywebapp09'

  
  vmImageName: 'ubuntu-latest'

stages:
- stage: Build
  displayName: Build stage
  jobs:
  - job: Build
    displayName: Build
    pool:
      vmImage: $(vmImageName)

    steps:
    - task: ArchiveFiles@2
      displayName: 'Archive files'
      inputs:
        rootFolderOrFile: '$(System.DefaultWorkingDirectory)'
        includeRootFolder: false
        archiveType: zip
        archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
        replaceExistingArchive: true

    - upload: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
      artifact: drop

- stage: Deploy
  displayName: Deploy stage
  dependsOn: Build
  condition: succeeded()
  jobs:
  - deployment: Deploy
    displayName: Deploy
    environment: $(environmentName)
    pool:
      vmImage: $(vmImageName)
    strategy:
      runOnce:
        deploy:
          steps:
          - task: AzureRmWebAppDeployment@4
            displayName: 'Azure App Service Deploy: valleywebapp09'
            inputs:
              azureSubscription: $(azureSubscription)
              appType: webAppLinux
              WebAppName: $(webAppName)
              packageForLinux: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip'
              RuntimeStack: 'NODE|10.10'
              StartupCommand: 'npm run start'
              ScriptType: 'Inline Script'
              InlineScript: |
                npm install
                npm run build --if-present

关于azure - Azure 应用服务的间歇性部署问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76879212/

相关文章:

azure - 使用 terraform 的 Azure VM 上的 Tomcat?

javascript - Azure 存储 SAS token 在本地主机上工作,但部署在 Azure Kubernetes 上时不起作用

docker - 如何在Azure Pipelines中使用Docker主机服务连接

azure - 如何以及在何处在网络核心 Web 应用程序中设置 TelemetryClient?

azure - 是否可以将虚拟应用程序配置为在 Azure Web 应用程序中使用单独的应用程序池?

无法创建资源的 Azure 角色

Azure Functions ARM 模板部署删除函数

azure - 使用 Azure DevOps CI/CD 管道自动部署 ADF 管道

powershell - 通过 Powershell 从应用程序服务中删除自定义域/主机

azure - 如何将 parquet 文件从 Azure Blob 读取到 Pandas DataFrame 中?