Reduce deployment size of JS Azure Function App - javascript

I had followed this article a while back https://adrianhall.github.io/typescript/2020/01/12/fixing-functions-deployment/
To reduce the zip folder size of my JS Azure Function app. I tried to deploy today as normal (I use the azure function extension in VSCode to deploy) however it is getting stuck in the "Creating Zip package..." step. When this happened before I added node_modules/azure-functions-core-tools to the .funcignore file which has worked for the last few months. I'm assuming the reason it is stuck is due to the app size being too large.
Having ran the following to determine which node-modules were the largest -
du -ks node_modules/*/. | sort -rn
I got the following results
My question is - can I add node_modules/aws-sdk to the .funcignore file? or is this required in the deployment?
Any help would be greatly appreciated

I have tried to create a sample function in VS code, tried to publish from vs code to azure function app and got deployed successfully.
Output of the function running locally:
And I also excluded the node_modules/aws-sdk package by using the .funcignore file and published the function to the Azure App Service successfully as shown in the below screenshot:
Note: There is a limitation of azure zip deployment to 2 GB and If your zip deployment file size is more than 2 GB then it will stuck while deploying the FunctionApp.
You can exclude that particular package and publish to Azure without any issues.

Related

Aws server is not running

I have Nodejs code running on aws fargate container.
What I did just add one logic, tested code and pushed code to github. And AWS started pipeline process. When deployment failed I checked cloud watch to know why its failed.
So I found that my Nodejs code requrire one package to run #aws-sdk/middleware-endpoint.
When I tested my nodejs code in my local system I didn't received any such error.
Here is error I received in aws
After reading this error I installed package #aws-sdk/middleware-endpoint and my server is running well.
I am willing to know why #aws-sdk/middleware-endpoint is required suddenly. Although previously my all apis are working fine in same aws server, But today I saw requirement of #aws-sdk/middleware-endpoint.
Anyone can help me what is need of #aws-sdk/middleware-endpoint?

typeEror - o.map is not a function shows in react from hosted

I am making a MERN e-commerce project with redux.
I have hosted my backend in Heroku and my frontend is hosted in vercel .
everything running fine from localhost but when I open hosted site
then it shows "o.map is not a function" on console
Here is my project github link-
Frontend- https://github.com/arijitdas13105/Ashop-frontend-new
Backend- https://github.com/arijitdas13105/ashop-backend
My hosted website link - https://ashop-frontend-99x2ayoh7-arijitdas13105.vercel.app/products
My backend Product API - https://ashop-server.herokuapp.com/api/products
let me know anything else need.
When you host in vercel, your JS code is minified with react-scripts build (You can see it in your package.json). This o.map is other variable in your code, probably the products.map. You can solve this issue using products?.map instead, so it will try to render the elements only when it has content.
If the data is not load and you don't know why, I recommend you to run it with npm run dev and figure out the reason (you can use debugger or console.log).
You can see the Network Tab in your devtools to see what the backend is returning as well.

Gatsby development server stops working when repo is created on github. Sanity, Gatsby Error

I received a github repo backup from somebody elses account. The project is running gatsby, sanity cms and is hosted via netlify. When I extract the archive and saving the folder locally, I am perfectly able to get the gatsby development server runnning just by doing "yarn install" and "yarn gatsby develop".
However, when I create a new repo and import the project to my github account, the development server is not running anymore. We tried it on several machines and we always get the same error in terminal trying "yarn gatsby develop".
success open and validate gatsby-configs - 0.131s
success load plugins - 2.486s
success onPreInit - 0.038s
success initialize cache - 0.009s
success copy gatsby files - 0.091s
info [sanity] Fetching remote GraphQL schema
ERROR #gatsby-source-sanity_drafts.10003
[sanity] The token specified is not valid or has been deleted
How is that possible? I tried to fix this for days but I don't get it. The only differnce between being able to run the dev server and this error is to save the code to github... Is it maybe some sort of routing problem in the gatsby-config.js?
Would appreciate your help a lot!
It seems that you are missing the environment variables in your new projects so your Sanity configuration is not valid, hence Gatsby is not able to fetch the data from the sources.
There should be a .env.development or .env.production files in your original code placed in the root of the project.

Host static HTML in Azure Web App Service

I'm azure beginner
I've created nodejs service and deployed it to Azure Web App service, it works as expected.
So, I have resource group mars-app and existing Web App service application my-mars-web-app.
Now, I want to add static HTML file, to show it when user goes to root URL https://***.azurewebsites.net/
To achieve it,
I have cloned github repo with client side to azure storage with azure cli help
In cliend code folder, I have tried to run az webapp up -g mars-app -n my-mars-web-app --html, but every time I'm receiving:
The webapp my-mars-web-app is a Linux app. The code detected at '/home/serhii/azure-website' will default to '<module 'os' from '/opt/az/lib/python3.6/os.py'>'. Please create a new app to continue this operation.
Because of above error, I have added index.html to dist diretory in my backend app
app.get('/', function (req, res) {
res.sendfile('dist/index.html');
});
and it works. But I'm not sure it is a good solution
What the best practice to add static HTML files to existing Web App service?
This question may be a dublicate of this question, but it was asked 5 years ago, so maybe something changed.
P.S. I know about Static Web Apps, but it is in preview and I'm interested in more generic solutions.
Thanks in advance
[UPDATE]
Here an article about deploying react app
Why you want to add static HTML files to existing web app services, for update or others?
In my opinon, now that you have used git, you can use continuous deployment.
When you modify your program (add new or modify files), in the Action of github, you will see the program start to deploy again. This should be the best deployment plan.

Parse.com To Do web app deployment issue

Apologies for basic question. I am very new in web development . I have download parse.com javascript web To Do App from https://parse.com/tutorials/todo-app-with-javascript . Now I want to deploy with parse.com. So that I can browse this app using http://mytestapp.parseapp.com. But when try to deploy using "parse deploy" command getting error as "Command must be run in a directory containing a Parse project."
Can you please help out me by step by step process.
Did you follow deployment rule of parse?
If your directory structure (from where you run command) is not as below you'll get the same error:
-config/
global.json
-cloud/
main.js
-public/
index.html
If the keys config/global.json do not matches to yours then also you'll error.

Categories