azure - Azure 静态 Web 应用中的部署槽如何工作

标签 azure azure-devops yaml azure-static-web-app azure-deployment-slots

我在 Azure 门户中创建了一个静态 Web 应用程序,用于托管我的 Angular 应用程序。创建向导自动在我的 Azure Repo 中生成管道。如果我转到 Azure DevOps,我可以看到管道的 YAML,如下所示:

name: Azure Static Web Apps CI/CD

pr:
  branches:
    include:
      - master
trigger:
  branches:
    include:
      - master

jobs:
- job: build_and_deploy_job
  displayName: Build and Deploy Job
  condition: or(eq(variables['Build.Reason'], 'Manual'),or(eq(variables['Build.Reason'], 'PullRequest'),eq(variables['Build.Reason'], 'IndividualCI')))
  pool:
    vmImage: ubuntu-latest
  variables:
  - group: Azure-Static-Web-Apps-purple-bush-094d6d303-variable-group
  steps:
  - checkout: self
    submodules: true
  - task: AzureStaticWebApp@0
    inputs:
      azure_static_web_apps_api_token: $(AZURE_STATIC_WEB_APPS_API_TOKEN_PURPLE_BUSH_094D6D303)
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
      app_location: "/" # App source code path
      api_location: "" # Api source code path - optional
      output_location: "dist/propworx-portal" # Built app content directory - optional
###### End of Repository/Build Configurations ######

因此,这将构建我的存储库的主分支并将其发布到生产环境。

现在我真的是一名后端开发人员,之前只使用过 Azure Web Apps。这是我第一次使用 Azure 静态 Web 应用。在 Azure Web Apps 中,我将创建部署槽,并将我的暂存分支部署到我的暂存槽。测试后,我将交换暂存槽和生产槽。

我正在努力弄清楚如何使用 Azure 静态 Web 应用来重现某些内容,至少是类似的内容。 Azure 门户上没有“部署槽”部分。如果我理解正确的话,插槽会根据我的存储库分支自动创建吗? (以及我为他们创建的管道?)。因此,我认为我需要创建一个新的管道来构建我的暂存分支并将其发布到暂存槽。但是,当我尝试这样做时(通过创建新管道并复制粘贴主管道的 YAML)并将 YAML 中的“分支”从“master”更改为“staging”,然后手动运行管道,它仍然部署到与其他主管道相同的 URL。我需要将其部署到不同的 URL(即不同的插槽)。此外,当我将提交推送到暂存分支时,管道不会自动运行,就像我将提交推送到主分支时主管道运行的方式一样。

任何指导/提示/指示将不胜感激! 谢谢。

最佳答案

静态 Web 应用程序没有部署槽,但有称为预览环境的东西。您可以使用 deployment_environment 输入控制部署任务部署到的环境。

可以找到文档 from here 。我并没有真正使用太多环境分支,但我猜想从暂存分支部署到暂存槽最接近的等效方法是将deployment_environment设置为要使用Web应用程序部署到生产槽中的任何分支,来自该分支和登台分支的管道触发器。

关于azure - Azure 静态 Web 应用中的部署槽如何工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75615319/

相关文章:

azure - 端点不支持 BlobStorageEvents 或软删除异常

azure - 我从 Azure 通用工件下载了工件,但下载的是哪个路径

node.js - 是否有可能在 Azure 上获得 IIS 的免费 ssl 证书

azure - 无需用户登录即可从 Azure 应用程序访问 token

Azure Function function.json 文件丢失

在阶段之间传播期间第二次访问时,Azure Pipeline 变量值会丢失

azure - 是否可以使用 Azure Devops API 访问组织范围的工件源?

java - 从 YAML 文件 : No content to map due to end-of-input 读取时出现 JsonMappingException

flutter - 我如何在 pubspec.yaml 中添加用户定义的变量以进行 flutter ?

azure - 在 Cache@2 Azure Devops 任务的 key 中使用节点版本