Webapp ARM template, how build MSDeploy zip after deploy

laurent-14 146 Reputation points
2021-02-17T14:54:59.173+00:00

Hello,

Till now I have succeeded to make an ARM template for a web app, using the extension MSDeploy (with packageUri zip in an azure blob storage).
Inside the package zip file, I have a create-react-app with all files (package.json, node_modules, src, ...), but without the build folder.

But my problem is that I would like to build the application on the azure web app, in order to load some environment variables from the server app settings (if I build the application locally it cannot see the server app settings).

So here I am -> how in ARM template indicate that after unzip on wwwroot, the application must be build.
(until now I have used the .deployment file with SCM_DO_BUILD_DURING_DEPLOYMENT=true, but that file has no effect using ARM template to create the resource, no build folder is created)

other things I have tried :

  • putting SCM_DO_BUILD_DURING_DEPLOYMENT in appsettings (it was indicated somewhere to do that for azure functions, but here for webapp seems useless)
  • try to run the webapp with "npm start" command because this would avoid the building problem, but for create-react-app I have not succeeded to start the webapp server like that yet
  • looking at new Microsoft.Resources/deploymentScripts, maybe could do the build if it cannot be configured in Microsoft.Web/sites ARM

Thanks for your help,
laurent

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,323 questions
{count} votes

Accepted answer
  1. ajkuma 24,561 Reputation points Microsoft Employee
    2021-03-09T11:18:19.557+00:00

    To benefit the community find the answer quickly, summarizing the comments :

    laurent-33 used the webjob to run a bash script for updating the environment variable into the react app before running it.

    Alternate approach: via ZipDeploy. MSDeploy assumes the package containing already built artifact and do not support the mentioned appSettings.
    https://github.com/projectkudu/kudu/wiki/MSDeploy-VS.-ZipDeploy

    @laurent-14 - thanks for sharing the solution that worked for you with the community. It's much appreciated.

    0 comments No comments

0 additional answers

Sort by: Most helpful