我正在尝试将一个极其简单的静态 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。这就是我所做的:
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 ######
{
"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"
}
]
}
[
{
"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"
}
}
}
]
我通过使用带有
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 美元用于测试应用程序的技术支持)。