Strapi zip deploy to Azure, missing /admin folder

System Information
  • Strapi Version:
  • Operating System:
  • Database:
  • Node Version:
  • NPM Version:
  • Yarn Version:

I am deploying strapi as a zip deploy, everything is uploaded but when I start the app in the address I get

http://myapp.azurewebsites.net/admin/runtime~main.1b2fae89.js net::ERR_ABORTED 404 (Not Found)
myapp.azurewebsites.net/:15 GET http://myapp.azurewebsites.net/admin/main.2ee68921.chunk.js net::ERR_ABORTED 404 (Not Found)
favicon.ico:1 GET http://myapp.azurewebsites.net/favicon.ico 404 (Not Found)

I have build the project using yarn build, and setting to ENV=Production

I zipped the build folder and using curl posted that to server:
curl -X POST -u $User --data-binary @“C:\Users\Administrator\Desktop\build.zip” Sign in to your account

1 Like

This is not how you should deploy it. You should deploy the whole project to azure and run it with yarn start or by using pm2.

Build folder contains only the Frontend.

Take a look at the deployment process for azure.

thanks for pointing this, I actually tried to deploy everything, but it couldn’t upload everything, after a time a got errors with response to server error.
I try to zip deploy to Azure as a web app using this tutorial : github-strapi-web-app

the last steps I did:
yarn build setting ENV=Production

then zip a strapi project and using that same curl command to upload it

could be the problem, is that Strapi does not recommend deploying to Azure as a web app?

We don’t recommend the serverless side of Azure as it certainly was not designed with applications like Strapi in mind. I have spend an ungodly amount of time trying to make it work properly with at least decent performance (I’ve never gotten it to successfully deploy).

ok, so should I just forget trying to deploy as a web app then. I mean even if it will work from my understanding it wouldn’t work properly though as a webapp as it was not intended so

I’ve seen others get it to work with substantiation “hacking and workarounds” to get it to function properly.

I am going try again, to upload the whole project using curl, if not then will go for official setup. Its just that my boss asked to deploy as a webapp, so I thought give it a try, found tutorial. But yes I see the downfalls and why its not advised initially. Thanks @DMehaffy will post here if I got it to work as a webapp, maybe someone else trying…

If anyone else has experience in the community (and you are reading this) who is willing to contribute a detailed guide to the documentation on Azure webapp deployment I would love to see a PR for it.

I’m fairly certain trying to write that guide myself has contributed to about a 20% hair loss on my head.

image

2 Likes

I got it definitely working on an App Service as a docker container, that is how it is working for me atm … but i mean i got it also working as a nodejs deployment. For the later one i have to work it out again. I will not promise something, but i think i could do the task.

Just to clear something up, Azure web apps are not serverless.

@Aytac_Kirmizi did you have any issues?

I’ve losely followed this GitHub - abachuk/azure-demo-strapi: strapi demo deployment to azure + docker

the container builds fine but it will not connect to a remote sql server for love nor money - it seems like it ignores all environment variables set in the azure admin. In fact despite the docker file being set to production AND even my database.js is only setup for mysql the container deploys with a local sqllite db - its driving me nuts.

there should be no reason for this not to work.

I did

No issues here :slight_smile:

well, the problem could be your project structure.
image

The default one - on the root level of the config folder - is the one which is used for the staging and production stages. Both stages has their own MySQL Database and both will be deployed as a docker container. Here how it looks…
image

My Configuration within the App Service looks like the following…

The Docker File in the linked project, is copying everything to the destination. In my case I am only copying selected folders/files to the destination.

FROM node:14-alpine

ENV PORT 1337
ENV HOST 0.0.0.0
ENV NODE_ENV production

# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

# Install app dependencies
COPY package*.json /usr/src/app/
COPY yarn.lock /usr/src/app/

RUN yarn install

COPY ./api /usr/src/app/api
COPY ./components /usr/src/app/components
COPY ./extensions /usr/src/app/extensions
COPY ./config /usr/src/app/config
COPY ./public /usr/src/app/public
COPY ./nc /usr/src/app/nc
COPY favicon.ico /usr/src/app/

# Bundle app source
#COPY . /usr/src/app

RUN yarn build
EXPOSE 1337

CMD ["yarn", "start"]

That is how it works for me, I got it also to work as a plain nodejs deployment, but this runs as also as a docker container at the end, bc of that I didn´t wrote something about that. If someone is interested here is the Build pipeline:

# Node.js
# Build a general Node.js project with npm.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript

trigger:
- master

resources:
- repo: self

variables:
  tag: '$(Build.BuildId)'
    # Agent VM image name
  vmImageName: 'ubuntu-latest'


stages:
- stage: Package
  displayName: Create NodeJS Package & upload as artifact
  jobs:
  - job: Package
    displayName: Package
    pool:
      vmImage: $(vmImageName)
    steps:
    - task: Bash@3
      displayName: Build strapi package
      inputs:
        targetType: 'inline'
        script: |
          yarn install
          yarn add lodash

          rm -rf .cache
          rm -rf .git
          rm -rf exports
          rm -rf build
          rm -rf .devcontainer

          rm -rf run.sh
          rm -rf README.md
          rm -rf migrate-*

          rm -rf Dockerfile*
          rm -rf docker-entr*
          rm -rf .dockerignore

          rm -rf *.code-workspace
          rm -rf azure-pipe*
          rm -rf .gitignore
          rm -rf .es*
          rm -rf .editorconfig
          rm -rf .strapi-updater.json
          rm -rf yarn.lock

    - task: ArchiveFiles@2
      displayName: Create zip package
      inputs:
        rootFolderOrFile: './'
        includeRootFolder: false
        archiveType: 'zip'
        archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId)_plain.zip'
        replaceExistingArchive: true

    - task: PublishBuildArtifacts@1
      displayName: Upload as Artifact
      inputs:
        PathtoPublish: '$(Build.ArtifactStagingDirectory)'
        ArtifactName: 'drop'
        publishLocation: 'Container'

Here the release config:

I hope I could help

@Aytac_Kirmizi - A massive thank you for this.

The secret sauce - the NODE_ENV is not followed (curious why?) and thus the production config must be the default as you have it set.

Sometimes the most obvious answer stares you in the face.