gpt4 book ai didi

reactjs - 通过 Azure CLI 基于 Azure DevOps git 存储库部署 ReactJs Azure 静态 Web 应用程序

转载 作者:行者123 更新时间:2023-12-03 00:21:41 27 4
gpt4 key购买 nike

我实际上正在为使用 Azure Static Web App 在 ReactJs 中制作的 UI 项目开发持续交付管道。我想基于 Azure DevOps 中的 git 存储库创建静态 Web 应用程序并将其部署到 Azure。这背后的原因是我看到了一个巨大的机会,可以使用静态 Web 应用程序为我每天使用的系统创建拉请求环境管道,这似乎是一个 super 便宜且快速的解决方案!然后,管道将允许在发布到 DEV、QA 等产品环境之前单独测试 Pull 请求更改。

总之,言归正传。 The official Microsoft documentation仅提供了如何对 GitHub 存储库执行此操作的示例,但我找不到任何有关如何在使用 Azure DevOps git 存储库时实现此目的的信息:

az staticwebapp create \
-n my-first-static-web-app \
-g <RESOURCE_GROUP_NAME> \
-s https://github.com/<YOUR_GITHUB_ACCOUNT_NAME>/my-first-static-web-app \
-l <LOCATION> \
-b main \
--app-artifact-location "build" \
--token <YOUR_GITHUB_PERSONAL_ACCESS_TOKEN>

我认为 az staticwebapp create 在提供的示例中的工作方式应该与 Azure DevOps 类似。我认为 Azure DevOps 中的 YOUR_GITHUB_PERSONAL_ACCESS_TOKEN 相当于可以生成的访问 token : enter image description here

当我尝试运行以下代码时:

az staticwebapp create -l westus2 -n appNameTest1 -g TestPrEnvResourceGroup -s "https://dev.azure.com/myOrganizationName/myProjectName/_git/myRepoName -b "main"--token "generatedTokenValuefwfsdgsgsd"

我遇到以下异常;

命令组“staticwebapp”处于预览状态并正在开发中。引用和支持级别:https://aka.ms/CLI_refstatus 操作返回无效状态“错误请求”

enter image description here

此外,我认为这并不重要,但 TestPrEnvResourceGroup 是在 UK West 位置下创建的。它并没有告诉我太多信息,比如 token 或其他参数是否错误......

有什么想法吗?干杯

最佳答案

你试过吗this way

您需要从 Azure 静态 Web 应用生成部署 token 并将其包含在 YAML 中

我对 Angular app 尝试了同样的操作而且效果很好

 azure_static_web_apps_api_token: $(deployment_token)

更新:根据 Github issue ,目前不支持。

We currently don’t support automatically creating Azure DevOpspipelines. This is the supported path for using Azure DevOps:https://learn.microsoft.com/en-us/azure/static-web-apps/publish-devops

您可以为该功能投票here

关于reactjs - 通过 Azure CLI 基于 Azure DevOps git 存储库部署 ReactJs Azure 静态 Web 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67702715/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com