How to deploy node application to Azure staticweb app

476 views Asked by At

We have created AZURE Static WebApp and Private endpoint in Azure cloud and the Static webapp fqdn is mapped to the privateendpoint ip by creating the DNS record in Private DNS zone.

Now the nslookup and name resolution is showing fine when we are testing it from the same virtual network range and telnet over 443 also working.

As a next step we were trying to deploy the node apps .dist folder using swa cli command line as below and which is getting failed.

swa deploy ./dist/ --env production --deployment-token xxxxxxxx

Welcome to Azure Static Web Apps CLI (1.1.2)

Deploying front-end files from folder:
  /home/user/swa/test/dist

Consider providing api-language and version using --api-language and --api-version flags,
    otherwise default values apiLanguage: node and apiVersion: 16 will apply

Deploying to environment: production

Deploying project to Azure Static Web Apps...
✖ Failed to contact content server, stopping...
✖ An unknown exception has occurred
3

There are 3 answers

0
Firas Haj-Husein On BEST ANSWER

When it comes to content deployment in Static Web Apps, the private endpoints are irrelevant, as the Static Web App is not accessed during the deployment, unlike the situation with web/function apps.

There are a few endpoints that are required for the deployment to succeed. These endpoints are dynamic, but they are determined on the creation of the Static Web App, and never change after that. The endpoints are:

  1. swalocaldeploy.azureedge.net
  2. registry.npmjs.org
  3. The Content Distribution endpoint: This is specified by the “contentDistributionEndpoint” property in the Static Web App ARM resource. You can simply find it by going to the Static Web App in the portal -> JSON View. It will look something like this: https://content-dm1.infrastructure.3.azurestaticapps.net.
  4. The Azure Storage service tag. You can either choose to allow-list the entire Storage service tag, or you can restrict it to just the Storage service tag for the same region as your Static Web App.

The last two are the ones that are dynamic, but again, they never change for a Static Web App.

0
Ryan Hill On

I'm assuming your running the cli command from a VM attached to the same vnet, similar to this workflow, since you stated that nslookup returns the correct record.

Based on what you posted, I was reading through deploy.ts to see where it may have failed. I came across Swa deploy fails with an unknown exception has occurred and it sounds very similar to your issue; however, no resolution was posted. I would run swa deploy --verbose=silly to see how far down it goes before it finally failed. My assumption is the deploy command is either using the original SWA endpoint which is not receiving internet traffic and not using the PE.

I've posted this question on that GitHub issue, and I'll reach out to the PM team for further investigation.

0
Thomas Gauvin On

I'm a product manager on Static Web Apps. It seems possible that with the configuration you described, you are attempting to deploy to Static Web Apps from your private network over the private endpoint (similar to this thread on our community GitHub https://github.com/Azure/static-web-apps/issues/1245)

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 investigating however.

Hope this helps!