Azure / static-web-apps-cli

Azure Static Web Apps CLI ✨
https://aka.ms/swa/cli-local-development
MIT License
594 stars 117 forks source link

Deploy fails with no feedback, application is not deployed, stuck in "Uploading" forever #816

Closed Peter-Juhasz closed 2 months ago

Peter-Juhasz commented 6 months ago

Describe the bug

Deploy fails with no feedback.

To Reproduce

swa deploy --deployment-token REDACTED

Output:

Welcome to Azure Static Web Apps CLI (1.1.7)

Deploying front-end files from folder:
  C:\REDACTED\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: preview

Deploying project to Azure Static Web Apps...

The CLI exits here without any other message, no error either.

Azure Portal shows "Uploading":

image

Expected behavior Like any feedback from the app why it fails?

Device info (if applicable):

Additional context The application is very simple, consists of an html file, and a css file.

The SWA resource was just created, completely new, there was nothing deployed earlier.

lstorka commented 6 months ago

Had the exact same problem and when I investigated the logs, one line caught my eye: ℹ Current directory cannot be identical to or contained within artifact folders.

So I just navigated one directory up and then ran: swa deploy --env production -a .\frontend and now it was successfully deployed 😃

Peter-Juhasz commented 6 months ago

@lstorka Thanks for the workaround! It worked!

coder925 commented 6 months ago

The workaround works.

If you run the successful command but with --dry-run added you will see information still suggesting an error:

i Could not get event info. Proceeding i The content server has rejected the request with: BadRequest i Reason: Missing request content.

Also, if you navigate up two directories: swa deploy --env production -a .\dist\frontend it stops working again. The CLI just returns to command prompt without writing the success message "Project deployed". No warning or errors are given.

conradagramont commented 5 months ago

Setting the variables in the config file and having the proper folder structure is key. BTW, I'd recommend always running the cli with the --verbose silly switch.

I just wrapped up a blog post that could help shed some light on this. Using Azure Functions with Astro and Entra ID Authentication

JohanJimenex commented 2 months ago

🤦‍♂️In my case it was because I had a "*" in a path in the "staticwebapp.config.json" file and I just can saw

"routes": [
    {
      "route": "*",
      "allowedRoles": ["authenticated"]
    },
    ...

I replace it with :

"routes": [
    {
      "route": "/",
      "allowedRoles": ["authenticated"]
    },
    ...

By the way, in the documentation it says that we can use "/*" but this causes it to fail too

(I could only realize because I recorded the screen in slow motion, the log that appears in the console too quickly)

adrianhall commented 2 months ago

I see that this is now resolved - thanks for the community for jumping in!