Azure / Azure/static-web-apps

Managed NextJS API's no longer linked, App Insights logs no longer functional

Open
#1,417 14 comments 0 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**

I have two static web apps, both using NextJS. They're effectively identical: Standard Hosting + Enterprise Grade Edge + Custom Domain enabled, same codebase, and deployed via Azure Pipelines. This morning, after a code merge, both pipelines ran as expected (one right after the other, 5 minute build time), but environment A no longer has a managed backend API detected while environment B does. While environment A remains functional, it no longer sends logs to the already-connected Application Insights instance.

Because there is a regular health-check probe, here is an example of what App Insights for environment B (the still-connected environment) should look like:

![image](https://github.com/Azure/static-web-apps/assets/774314/ddecf4f4-ac36-4ec4-b003-22ac02928155)

Meanwhile, this is what environment A (no longer connected) looks like, with the logs completely disappearing at the time of the deployment:

![image](https://github.com/Azure/static-web-apps/assets/774314/56693c49-58b7-4088-8033-113f58598e10)

**To Reproduce**
Steps to reproduce the behavior:

* Run Azure Pipeline below
* Open Static Web App A in Azure
* Open the API tab
* Note that the tab does not have a `(managed)` API (first screenshot)
* Open Static Web App B in Azure
* Open the API tab
* Note that the tab does have a `(managed)` API (second screenshot)

![image](https://github.com/Azure/static-web-apps/assets/774314/88679e01-af82-4053-94a0-0a2fdaf53527)

![image](https://github.com/Azure/static-web-apps/assets/774314/790ac18d-e1eb-4a11-ae11-333d4760d766)

Here is the Pipeline yml for the no-longer-functional environment.

```yml
name: Azure Static Web Apps CI/CD

pr:
branches:
include:
- main
trigger:
branches:
include:
- main

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:
- name: NEXT_PUBLIC_GTM_ID
value: REDACTED
- group: REDACTED
steps:
- checkout: self
submodules: true
- task: NodeTool@0
inputs:
versionSource: 'spec'
versionSpec: '18.x'
- task: AzureStaticWebApp@0
inputs:
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: "/" # App source code path
api_location: "" # Api source code path - optional
output_location: "" # Built app content directory - optional
###### End of Repository/Build Configurations ######
```

And here is the yaml for the still-connected environment.
```yml
name: Azure Static Web Apps CI/CD

pr:
branches:
include:
- main
trigger:
branches:
include:
- main

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: REDACTED
steps:
- checkout: self
submodules: true
- task: NodeTool@0
inputs:
versionSource: 'spec'
versionSpec: '18.x'
- task: AzureStaticWebApp@0
inputs:
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: "/" # App source code path
api_location: "" # Api source code path - optional
output_location: "" # Built app content directory - optional
###### End of Repository/Build Configurations ######

```

**Expected behavior**
Both environments should show a `(managed)` API, with API logs connected to Application Insights

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Device info (if applicable):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Additional context**
Triggering a re-run of the pipelines does not change the outcome.

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.