简体   繁体   English

azure static web 应用程序,如何从同一个 git 回购中构建两个不同的 web 应用程序(一个产品和一个非产品)?

[英]azure static web app, how to have two different web apps (one prod and one non prod) building from the same git repo?

We have two static apps, one for production and one for non production (test).我们有两个 static 应用程序,一个用于生产,一个用于非生产(测试)。 They just show a site down page for when our main site on AEM is down (using traffic manager to switch).当我们在 AEM 上的主站点关闭时(使用流量管理器切换),他们只是显示一个站点关闭页面。

The source is held in an Azure devops git repo.源代码保存在 Azure devops git repo 中。

This is how it is built in non prod:这就是它在非产品中的构建方式:

trigger:
  - main

pool:
  vmImage: ubuntu-latest

steps:
  - checkout: self
    submodules: true
  - task: AzureStaticWebApp@0
    inputs:
      app_location: '/'
      api_location: ''
      output_location: ''
      azure_static_web_apps_api_token: $(deployment_token)

Now we want to make it build a prod version of the static web app, if we push to another branch (eg "prod").现在我们想让它构建 static web 应用程序的生产版本,如果我们推送到另一个分支(例如“prod”)。 Any idea how we might do this?知道我们该怎么做吗? Not sure how we would differentiate between the prod static web app deployment token and the non prod one either?不确定我们如何区分产品 static web 应用程序部署令牌和非产品?

Please take a look on this example .请看看这个例子 Here you have three main steps:这里有三个主要步骤:

  • in stage Build - a package is being prepared在 Build 阶段 - 正在准备 package
  • in stage Dev - package is being deployed to Dev env在阶段 Dev - package 正在部署到 Dev env
  • in stage Prod packages is being deployed to Prod env在阶段 Prod 包正在部署到 Prod env

It is implementation of approach build once deploy many, which is good because it means that on each env you use the same package, so you trully test the package which is going to be deployed to production.它是一次构建多次部署的方法的实现,这很好,因为这意味着在每个环境中你使用相同的 package,所以你真正测试将要部署到生产环境中的 package。

In terms of token, you can put this is two seprate variables group.就令牌而言,您可以把它放在两个单独的变量组中。 One name dev, and the other prod.一个名称为 dev,另一个名称为 prod。 Both should have the same variable deployment_token and then两者都应该有相同的变量deployment_token然后

- stage: Prod
  dependsOn: Dev
  variables:
  - group: Prod

- stage: Dev
  dependsOn: Build
  variables:
  - group: Dev

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 是否可以从另一个内部 Azure Static Web 应用程序调用一个 Azure Function 应用程序? - Is it possible to call one Azure Function from another inside Azure Static Web Apps? App Insights 仅适用于 Static Web 至少有一个 function 的 App - App Insights is only applicable to Static Web Apps with at least one function 如何使用 Azure 应用服务域 Static Web 应用程序? - How to use Azure App Services domain for Static Web Apps? 多个 web app static outbound IPs with one NAT Gateway(Azure) - Multiple web app static outbound IPs with one NAT Gateway(Azure) 如何将 ECR Docker 图像标记为生产和非生产 - How to tag ECR Docker Images as prod and non-prod 在 Azure Static Web 应用程序上添加身份验证 - Adding authentication on Azure Static Web Apps 从 Prod 为 Azure SQL 创建开发环境 - Dev Environment creation from Prod for Azure SQL Visual Studio Web 将 ASP.NET 应用程序发布到 Azure Web 应用程序结果为 Forbidden,除了来自一个分支、一台计算机的代码 - Visual Studio Web Publish ASP.NET app to Azure Web App results in Forbidden except for code from one branch, one computer Azure Static Web App - Function App API - 如何加载 IOptions? - Azure Static Web App - Function App API - How to load IOptions? 您如何使用别名将您的 AWS lambda 从一个 envr 转移/升级到另一个(例如,dev 到 prod)? - How do you shift/escalate your AWS lambda from one envr to another (eg. dev to prod) using alias?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM