Azure / static-web-apps

Azure Static Web Apps. For bugs and feature requests, please create an issue in this repo. For community discussions, latest updates, kindly refer to the Discussions Tab. To know what's new in Static Web Apps, visit https://aka.ms/swa/ThisMonth
https://aka.ms/swa
MIT License
330 stars 57 forks source link

Failed to contact content server, stopping... #1245

Open SnorkyPeho opened 1 year ago

SnorkyPeho commented 1 year ago

Deployment of a static web app using an Azure DevOps Release Pipeline is failing with error:

DeploymentId: 46602efe-c8e2-4ea8-a640-35b5c7faac90

Verbose logging enabled
Try to validate location at: '/working_dir/...'.
Build timeout not specified, defaulting to 15 minutes
App Directory Location: '...' was found.
Try to validate location at: '/working_dir/swa-db-connections'.
Try to validate location at: '.../staticwebapp.config.json'.
config_file_location: config file '.../staticwebapp.config.json' was found.
Looking for event info
Could not get event info. Proceeding
##[error]Failed to contact content server, stopping...
##[error]An unknown exception has occurred
##[error]Failed to record upload telemtry.

##[warning]For further information, please visit the Azure Static Web Apps documentation at https://docs.microsoft.com/en-us/azure/static-web-apps/
##[warning]If you believe this behavior is unexpected, please raise a GitHub issue at https://github.com/azure/static-web-apps/issues/
##[warning]Exiting
##[error]Error: The process '/usr/bin/bash' failed with exit code 1
##[section]Finishing: Deploy Static Web App

We are using a self-hosted agent on a Azure Virtual Machine Scaleset (VMSS) with Ubuntu 20.04 LTS and docker installed.

Deployment target is a static web app with a private endpoint. The VMSS instance has access to the VNET containing the static web app.

The error occurs constantly since 21/07/2023.

Release Pipeline YAML:

steps:
- task: AzureStaticWebApp@0
  displayName: 'Deploy Static Web App'
  inputs:
    app_location: /...
    config_file_location: ...
    skip_app_build: true
    skip_api_build: false
    is_static_export: false
    verbose: true
    azure_static_web_apps_api_token: '$(static_webapp_deployment_token)'

staticwebapp.config.json:

{
  "navigationFallback": {
    "rewrite": "/index.html",
    "exclude": ["*.{css,scss,js,png,gif,ico,jpg,svg}"]
  },
  "globalHeaders": {
    "Strict-Transport-Security": "max-age=63072000; includeSubdomains; preload",
    "X-Frame-Options": "sameorigin",
    "X-Content-Type-Options": "nosniff",
    "Referrer-Policy": "same-origin"
  },
  "routes": [
    {
      "route": "*.html",
      "headers": {
        "Cache-Control": "no-store"
      }
    }
  ]
}
sekoch commented 1 year ago

Same problem here... Deployment from VMSS (inside a vnet) to a static web app with private endpoint does not work with the error above.

Default azure devops agent can deploy to a static web app (no private endpoint) without any problems. I also don't find anything in the web. Any missing dns entries?

Thanks in advance!

AlexanderButz commented 1 year ago

Same problem. VMSS inside a vnet running custom build agents.

thomasgauvin commented 1 year ago

Today, private endpoints does not apply to deployment to Static Web Apps. Deployment cannot be restricted to a private endpoint due to the distributed nature of Static Web Apps content hosts.

This is an area we are actively investigating to improve Static Web Apps for your needs, can we get in touch @sekoch @AlexanderButz @SnorkyPeho?

My email is firstnamelastname microsoft com, or you can DM me on Twitter @thomasgauvin

reece-mccarthy commented 11 months ago

We encountered the same issue while deploying one specific SWA using a VMSS agent. When we redeployed it using an MS self-hosted agent, the problem did not occur.

Is there a reason this problem seems to be isolated to just 1 out of our 50 SWAs? Any insights or suggestions on why this might be happening selectively to just one SWA would be greatly appreciated.

MATTHEWTAYLOR1995 commented 11 months ago

We encountered the same issue while deploying one specific SWA using a VMSS agent. When we redeployed it using an MS self-hosted agent, the problem did not occur.

Is there a reason this problem seems to be isolated to just 1 out of our 50 SWAs? Any insights or suggestions on why this might be happening selectively to just one SWA would be greatly appreciated.

Yeah we've been having the same problem, we've been fine using the SWA deployment task over the last year or so using our self hosted agents behind a private endpoint. Then all of a sudden last week we started getting the same error only on one of our SWAs, the rest are still fine though which is so odd....

thomasgauvin commented 11 months ago

@reece-mccarthy @MATTHEWTAYLOR1995 are you confirming that you have outbound public internet enabled on your runners that are deploying to your SWA resource, and that despite this, the runner cannot contact the server?

Some customers in the past have reported that their machines were updated & reconfigured, sometimes by other orgs, to restrict public internet outbound access on the runners, so this may be a similar case.

I would recommend involving support if you believe this issue isn't the result of a configuration issue. Also, to better debug, I would test using verbose: true in your configuration for your Static Web Apps deploy action https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/azure-static-web-app-v0?view=azure-pipelines#:~:text=%23verbose%3A%20%23%20boolean.%20Verbose.