Azure / Azure/static-web-apps

Azure Static Web Apps (SWA) Deployment Fails with Generic 'Failed' Message

Open
#1,615 0 comments 5 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
346
Forks
67
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**

We were experiencing an issue with our Azure Static Web Apps (SWA) deployment using GitHub Actions. When the "build and deploy" stage failed, the GitHub Actions workflow showed the following error message:

![Image](https://github.com/user-attachments/assets/5ed2f252-fd1b-44c1-83c5-4d93b150a96f)

```
---End of Oryx build logs---
Function Runtime Information. OS: windows, Functions Runtime: ~4, dotnetisolated version: 8.0
Finished building function app with Oryx
Found functions.metadata file
Zipping Api Artifacts
Done Zipping Api Artifacts
Zipping App Artifacts
Done Zipping App Artifacts
Uploading build artifacts.
Finished Upload. Polling on deployment.
Status: InProgress. Time: 0.0552924(s)
Status: InProgress. Time: 15.1737644(s)
Status: InProgress. Time: 31.4099191(s)
Status: InProgress. Time: 46.4592357(s)
Status: InProgress. Time: 61.5111982(s)
Status: InProgress. Time: 76.5629748(s)
Status: InProgress. Time: 91.6141935(s)
Status: InProgress. Time: 106.7068654(s)
Status: InProgress. Time: 121.8279021(s)
Status: InProgress. Time: 136.8759718(s)
Status: InProgress. Time: 151.9247998(s)
Status: Failed. Time: 166.9796139(s)
Deployment Failed :(
Deployment Failure Reason: Failed to deploy the Azure Functions.

For further information, please visit the Azure Static Web Apps documentation at https://docs.microsoft.com/en-us/azure/static-web-apps/
If you believe this behavior is unexpected, please raise a GitHub issue at https://github.com/azure/static-web-apps/issues/
Exiting
```

In the Azure SWA UI, we only saw a generic "Failed" message without any additional information. This made it difficult for us to troubleshoot the issue and identify the root cause.

![Image](https://github.com/user-attachments/assets/01375fa8-7de7-46c6-b58b-6f02fc404571)

**To Reproduce**
In our case the issue was our middleware registration function. This solution built/ran locally fine but is what apparently caused the error when deploying the azure functions. Removing this code entirely resolved the issue and allowed the functions to deploy.

```c#
public static class GlobalMiddleware
{
public static IFunctionsWorkerApplicationBuilder UseAllGlobalMiddleware(this IFunctionsWorkerApplicationBuilder builder)
{
var serviceProvider = builder.Services.BuildServiceProvider();
var middlewareTypes = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(a => a.GetTypes())
.Where(t => typeof(ITriggerMiddlewareBase).IsAssignableFrom(t) && !t.IsInterface && !t.IsAbstract);
foreach (Type middlewareType in middlewareTypes)
{
// Resolve middleware instance using DI container
var middlewareInstance = ActivatorUtilities.CreateInstance(serviceProvider, middlewareType) as ITriggerMiddlewareBase;

middlewareInstance?.UseMiddleware(builder);
}
return builder;
}
}
```
**Expected behavior**
When the deploy stage fails, we expect the GitHub Actions workflow or Azure SWA UI to provide more detailed and specific error messages or logs to help us troubleshoot the issue. The current behavior of showing only a generic "Failed" message in the Azure SWA UI and a vague error message in the GitHub Actions workflow makes it difficult to identify the root cause of the issue.

**Additional context**
OS Type : bullseye
Image Type : githubactions
Node : v18.20.5
Dotnet SDK : 8.0.405

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.