由于内部服务器错误,简单的静态 Web 应用程序无法部署到 Azure

问题描述 投票:0回答:1

我正在尝试将一个极其简单的静态 Web 应用程序框架部署到 Azure,但无法让它工作。我不断收到“InternalServerError”和“请稍后重试”的指令,但由于已经尝试和重试超过 24 小时,我怀疑这是否能帮我解决问题。

由于本应是 Azure 官方社区支持部分的 Microsoft Learn 问答网站不断删除我的“违反社区准则”问题,所以我在这里碰碰运气。

背景

我尝试部署的应用程序实际上是最小的测试应用程序。我在 Azure DevOps 上托管了一个存储库,其中包含来自

ng new
的默认 Angular 应用程序模板作为前端,以及通过 VS Code 中的 Azure Functions 扩展为 API 项目生成的默认 Azure Functions 入门项目。除了遵循将 Angular 应用程序部署为 Azure SWA 的基本第一步之外,没有什么其他的了。

本地尝试

至关重要的是,我已经使用 Azure Static Web App CLI 测试了所有这些,并且它可以在本地运行,因此项目本身似乎没有任何固有的错误。 SWA CLI 在我的项目主目录中创建了以下

swa-cli.config.json

{
  "$schema": "https://aka.ms/azure/static-web-apps-cli/schema",
  "configurations": {
    "test-app": {
      "appLocation": "source\\test-app",
      "apiLocation": "functions",
      "outputLocation": "dist\\test-app",
      "appBuildCommand": "npm run build",
      "apiBuildCommand": "dotnet publish -c Release",
      "run": "npm start",
      "appDevserverUrl": "http://localhost:4200"
    }
  }
}

当我运行

swa start
时,我可以在浏览器中打开
localhost:4280
并获得 Angular 应用程序,当我打开
localhost:7071/api/TestRequest
时,我会得到
Welcome to Azure Functions!
的响应。所以前端和 API 项目都可以工作。

但是,我根本无法将同样的东西部署到 Azure。这就是我所做的:

Azure 门户部署尝试

  1. 在我的 Azure 门户中,我选择 创建资源,然后选择 静态 Web 应用程序
  2. 从下拉列表中,我选择现有的订阅和资源组,并为应用程序命名,例如 test
  3. 我为 Azure Functions 选择了免费托管计划和西欧区域,尽管我也尝试了其他选项,但没有成功。
  4. 对于 Source,我选择 Azure DevOps,然后从下面的选择框中选择适当的 OrganizationProjectRepostioryBranch
  5. 对于 Build Preset,我选择 Angular,并为 App locationAPI locationOutput location 使用与上面显示的配置文件中相同的路径。
  6. 当单击 Review + create 然后单击 Create 时,首先会发生的事情是在我的 Azure DevOps 帐户中创建一个新的个人访问令牌,并将一个 YAML 文件提交到给定分支,如下所示:
name: Azure Static Web Apps CI/CD

pr:
branches:
  include:
    - deployment-test
trigger:
branches:
  include:
    - deployment-test

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-<redacted>-variable-group
steps:
- checkout: self
  submodules: true
- task: AzureStaticWebApp@0
  inputs:
    azure_static_web_apps_api_token: $(AZURE_STATIC_WEB_APPS_API_TOKEN_<redacted>)
###### 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: "/source/test-app" # App source code path
    api_location: "/functions" # Api source code path - optional
    output_location: "dist/test-app" # Built app content directory - optional
###### End of Repository/Build Configurations ######
  1. 转发到部署概览后,只需要几秒钟就出现红色错误栏,显示“部署失败,请点击此处查看详细信息”。显示的这些详细信息是:
{
"code":"DeploymentFailed",
"message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-deployment-operations for usage details.",
"details":[
  {
    "code":"InternalServerError",
    "message":"There was an unexpected InternalServerError.  Please try again later.  x-ms-correlation-request-id: 6e2ab150-1542-4756-bc65-19d207d7b4f7"
  }
]
}
  1. 按照说明检查部署操作详细信息,我得到以下进一步信息:
[
{
  "id": "/subscriptions/<redacted>/resourceGroups/<redacted>/providers/Microsoft.Resources/deployments/Microsoft.Web-StaticApp-Portal-48a26296-8238/operations/D5DB44C607F1BB9D",
  "operationId": "D5DB44C607F1BB9D",
  "properties": {
    "provisioningOperation": "Create",
    "provisioningState": "Failed",
    "timestamp": "2023-03-16T15:39:54.1309018Z",
    "duration": "PT4.4853634S",
    "trackingId": "66113984-7e07-4bf8-bcae-bdeb3024f87a",
    "statusCode": "BadRequest",
    "statusMessage": {
      "status": "Failed",
      "error": {
        "code": "InternalServerError",
        "message": "There was an unexpected InternalServerError.  Please try again later.  x-ms-correlation-request-id: 6e2ab150-1542-4756-bc65-19d207d7b4f7"
      }
    },
    "targetResource": {
      "id": "/subscriptions/<redacted>/resourceGroups/<redacted>/providers/Microsoft.Web/staticSites/test",
      "resourceType": "Microsoft.Web/staticSites",
      "resourceName": "test"
    }
  }
}
]

更新:Azure CLI 部署尝试

我通过使用带有

az staticwebapp create
标志的
--debug
CLI 尝试相同的部署来获得更详细的信息。这是我在日志中看到的关键部分:

cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions/<redacted>/resourceGroups/<redacted>/providers/Microsoft.Web/staticSites/test?api-version=2022-03-01'
cli.azure.cli.core.sdk.policies: Request method: 'PUT'
cli.azure.cli.core.sdk.policies: Request headers:
cli.azure.cli.core.sdk.policies:     'Content-Type': 'application/json'
cli.azure.cli.core.sdk.policies:     'Content-Length': '421'
cli.azure.cli.core.sdk.policies:     'Accept': 'application/json'
cli.azure.cli.core.sdk.policies:     'x-ms-client-request-id': 'a6d7bd28-c417-11ed-af62-00155d86942d'
cli.azure.cli.core.sdk.policies:     'CommandName': 'staticwebapp create'
cli.azure.cli.core.sdk.policies:     'ParameterSetName': '-n -g --api-location --app-location -b -l --login-with-ado --output-location --sku -s --debug --verbose'
cli.azure.cli.core.sdk.policies:     'User-Agent': 'AZURECLI/2.45.0 (MSI) azsdk-python-azure-mgmt-web/7.0.0 Python/3.10.8 (Windows-10-10.0.19042-SP0)'
cli.azure.cli.core.sdk.policies:     'Authorization': '*****'
cli.azure.cli.core.sdk.policies: Request body:
cli.azure.cli.core.sdk.policies: {"location": "westeurope", "sku": {"name": "Free", "tier": "Free"}, "properties": {"repositoryUrl": "<redacted>", "branch": "deployment-test", "repositoryToken": "<redacted>", "buildProperties": {"appLocation": "source/test-app", "apiLocation": "functions", "appArtifactLocation": "dist/test-app"}}}
urllib3.connectionpool: Starting new HTTPS connection (1): management.azure.com:443
urllib3.connectionpool: https://management.azure.com:443 "PUT /subscriptions/<redacted>/resourceGroups/<redacted>/providers/Microsoft.Web/staticSites/test?api-version=2022-03-01 HTTP/1.1" 500 36
cli.azure.cli.core.sdk.policies: Response status: 500
cli.azure.cli.core.sdk.policies: Response headers:
cli.azure.cli.core.sdk.policies:     'Cache-Control': 'no-cache'
cli.azure.cli.core.sdk.policies:     'Pragma': 'no-cache'
cli.azure.cli.core.sdk.policies:     'Content-Length': '36'
cli.azure.cli.core.sdk.policies:     'Content-Type': 'application/json; charset=utf-8'
cli.azure.cli.core.sdk.policies:     'Expires': '-1'
cli.azure.cli.core.sdk.policies:     'Strict-Transport-Security': 'max-age=31536000; includeSubDomains'
cli.azure.cli.core.sdk.policies:     'Server': 'Microsoft-IIS/10.0'
cli.azure.cli.core.sdk.policies:     'X-AspNet-Version': '4.0.30319'
cli.azure.cli.core.sdk.policies:     'X-Powered-By': 'ASP.NET'
cli.azure.cli.core.sdk.policies:     'x-ms-failure-cause': 'service'
cli.azure.cli.core.sdk.policies:     'x-ms-ratelimit-remaining-subscription-writes': '1199'
cli.azure.cli.core.sdk.policies:     'x-ms-request-id': '2d9ae5aa-8800-48d1-90ab-bb96a32f85fa'
cli.azure.cli.core.sdk.policies:     'x-ms-correlation-request-id': '2d9ae5aa-8800-48d1-90ab-bb96a32f85fa'
cli.azure.cli.core.sdk.policies:     'x-ms-routing-request-id': 'SWITZERLANDNORTH:20230316T162905Z:2d9ae5aa-8800-48d1-90ab-bb96a32f85fa'
cli.azure.cli.core.sdk.policies:     'X-Content-Type-Options': 'nosniff'
cli.azure.cli.core.sdk.policies:     'Date': 'Thu, 16 Mar 2023 16:29:05 GMT'
cli.azure.cli.core.sdk.policies:     'Connection': 'close'
cli.azure.cli.core.sdk.policies: Response content:
cli.azure.cli.core.sdk.policies: {"Message":"An error has occurred."}

所以,基本上,看起来我无能为力?我属于 Visual Studio Enterprise 订阅中包含的“每月 150 美元免费”套餐,但无权获得 Azure 上的技术支持。那么,Azure 对我来说就已经死了吗,没有追索权吗?

如何进行?

除非 Azure 完全损坏(我对此表示怀疑),否则我觉得必须有一些东西我可以更改或牢固地固定到位以部署 SWA。但我已经没有想法了,而且我觉得 Azure 没有给我足够的信息来知道下一步该去哪里。

如果有任何关于我下一步可以尝试的想法,我将非常感激! (还没有花费 29 美元用于测试应用程序的技术支持)。

azure azure-web-app-service azure-static-web-app
1个回答
0
投票

如果您使用免费版本的静态 Web 应用程序,您需要删除预览环境,因为在免费版本中您只能拥有 3 个。它们是随每个 PR 创建的,因此可以很快堆叠

enter image description here

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.