reactjs - 如何将 React 应用程序从 GitHub 部署到 Azure 应用服务

标签 reactjs azure powershell azure-web-app-service

嘿,我正在尝试使用 PowerShell 将我的 React 应用程序部署到 Azure 应用服务。好吧,我必须从 GitHub 部署它,并使用 PowerShell。

initialize -appCount 1

我有一个像上面这样的函数执行来创建 N 个应用程序。该函数包括以下几行:

$PropertiesObject = @{
    repoUrl = "$repoName";
    branch = "main";
    isManualIntegration = "true";
}

New-AzResourceGroup -Name $resourceGroupName -Location $location

New-AzAppServicePlan -Name $servicePlanName -Location $location -ResourceGroupName $resourceGroupName -Tier $tier

New-AzWebApp -Name $webAppName -Location $location -ResourceGroupName $resourceGroupName -AppServicePlan $appServicePlan

Set-AzResource -Properties $PropertiesObject -ResourceGroupName $resourceGroupName -ResourceType Microsoft.Web/sites/sourcecontrols -ResourceName $webAppName -Force

执行脚本后,它会创建一个网络应用程序。但是,它显示:

Website after unsuccessful deployment

而且,我收到此错误,但没有任何消息。

Powershell error

我尝试手动添加 GitHub 存储库来测试是否可以以某种方式部署我的 React 应用程序,即使我无法手动设置部署。但它又出现了这样的错误:

Deployment Center Error

我的问题是如何使用 PowerShell 将我的公共(public) GitHub 存储库中的 React 应用部署到 Azure 应用服务?

最佳答案

  • 即使出现错误,我也尝试使用 power shell 脚本进行部署。同时,如果您使用 power shell,则会缺少一些步骤。在将文件部署到存储库之前,请检查代码是否在本地系统中运行。
  • 如果我使用 power hell 将 GitHub 存储库部署到 azure,应用程序已成功创建,但未选择运行时堆栈,示例如下所示

enter image description here

  • 您的存储库没有packages文件夹。

  • 您提供的存储库无法正常工作,因此,我使用了另一个存储库,并使用以下步骤将 React 应用程序部署到 azure 门户

  • 打开azure门户并创建应用服务。创建应用服务后,转到部署中心并添加要添加到应用服务的GitHub存储库,如下所示

enter image description here

  • 点击Branch,它将重定向到 GitHub 位置 Goto Actions,如下所示

enter image description here

  • 点击上图第三步中的名称,将进入如下所示页面

enter image description here

  • 成功部署到 Azure 门户后,单击链接

enter image description here

关于reactjs - 如何将 React 应用程序从 GitHub 部署到 Azure 应用服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74916092/

相关文章:

reactjs - React onTransitionEnd 事件被频繁调用

javascript - 使用 JSX 和 React Native 的动态标签名称

azure - 仅对资源组具有 READER 访问权限的用户是否仍可以使用资源(不是管理,而是实际使用)

powershell - 查找数组中最大的时间

reactjs - 单击子组件时隐藏父 react 组件

javascript - 通过 map 获取具体结果

c# - 在 Visual Studio 中调试 Azure 函数

azure - 有没有办法使用 Azure 中的动态内容编辑器来计算字符串中存在的 "_"(下划线)的数量?

excel - 为什么Range.BorderAround向控制台发出 “True”?

windows - 在 Windows Server 2016 上使用 native tar PowerShell cmdlet