Azure / azure-dev

A developer CLI that reduces the time it takes for you to get started on Azure. The Azure Developer CLI (azd) provides a set of developer-friendly commands that map to key stages in your workflow - code, build, deploy, monitor, repeat.
https://aka.ms/azd
MIT License
402 stars 195 forks source link

[Issue] azd deploy excludes node modules by default for zip deployment of node.js projects #4215

Open tvriesde opened 1 month ago

tvriesde commented 1 month ago

In framework_service_npm.go node_modules seem to be excluded as part of the zip deployment.

This requires App Service deployments to have SCM_DO_BUILD_DURING_DEPLOYMENT=true for app services.

It would be helpful if this is mentioned in the azd documentation. (maybe i missed it)

and/or Node_module exclusion can be set as an option for azd deploy. So that developers can choose if they want to include node_modules in zip deployment or not.

rajeshkamal5050 commented 1 month ago

@weikanglim can you take a look and clarify?

weikanglim commented 1 month ago

@tvriesde Thanks a lot for mentioning this. You are indeed correct that SCM_DO_BUILD_DURING_DEPLOYMENT is needed in azd today for nom-based apps so that app service would run a full build remotely (npm install and npm build in this case) while being deployed.

Do you know what you ended up deciding on? Did setting SCM_DO_BUILD_DURING_DEPLOYMENT=true satisfy your needs, or would you have preferred to upload a fully built application?

At first glance, a nice thing to do here is for azd to probe the app service settings and act accordingly, since specifying SCM_DO_BUILD_DURING_DEPLOYMENT=false and not including node_modules wouldn't quite work. Alternatively, we could consider ignore options for deployment targets.

tvriesde commented 1 month ago

I chose to set SCM_DO_BUILD_DURING_DEPLOYMENT=true.

In the end this works for me. But I ran into this because initially the app did not work due to the modules not being present at the server.

When following the guidance from Microsoft. https://learn.microsoft.com/en-us/azure/app-service/configure-language-nodejs?pivots=platform-linux There is no mention of SCM_DO_BUILD_DURING_DEPLOYMENT. So AZD not including the node_modules, caused my app deployment to fail.

Even though I follow the article https://learn.microsoft.com/en-us/azure/app-service/configure-language-nodejs?pivots=platform-linux.

So there is a bit of friction, that can be improved by: Appending the documentation, or adapting the tool a bit, like you mention @weikanglim


When it comes down to the solution you present. This would have helped me indeed. Or presenting it as an option, so that I make an "ïnfromed" decision. Because zipping the node_modules might not always be the preferred scenario.

The downside of your solution is that I might not have gone down the route of SCM_DO_BUILD_DURING_DEPLOYMENT, which, could be the "preferred" option for certain use cases. There could be a difference in total deployment time for both scenario's, especially for larger projects.