NodeJS App Deployment via Azure DevOps 32bit issue - node.js

i am using Azure DevOps Build & Release to build my node.js react app that uses node-sass. So the Build is using the Node.js Tool Installer to specify the node.js version and then runs the npm install command. It all runs with a hosted agent that requires node.js and npm. The azure app service which runs the application is a default windows site.
After that i want to deploy it via Azure DevOps Release. I am using the Task "App Service Deploy" to deploy it. If i don't specify a deployment method it uses "Run from Package" and everything is fine. (Except that i cannot make changes in the root folder, but thats the concept of the run from package). If i change it to deploy via "Zip Deploy" i get the following error:
Error: Missing binding
D:\local\Temp\zipdeploy\extracted\node_modules\node-sass\vendor\win32-ia32-57\binding.node
Node Sass could not find a binding for your current environment:
Windows 32-bit with Node.js 8.x Found bindings for the following
environments: Windows 64-bit with Node.js 8.x
So i got this one already in my dev environment, but there i could get a simple workaround - install and use the 32bit version of node.js and then deploy it to azure (via VS Code extension). Now it is not possible to use 32bit nodejs in the Azure DevOps Build task as i saw as a limitation of the windows app services in azure.
How can i get Azure DevOps to use 32 bit when using npm install? Is the only possible way to switch to a linux app service (which runs 64bit) in azure?
Thanks!

Related

How to install dependent binaries on Azure App Service with Linux?

I have a spring boot application that I am running on Azure App Service (Linux). My application has a dependency on a binary and needs it to be present on the system. How do I install it on my App service?
I tried the following two options:
Did ssh via Kudu and installed the package ($ apk add package). But the changes are not persisted beyond /home. The dependencies were installed in other folders and when the app service was re-deployed all those dependencies were gone
Used the post deployment hook to run the command "$ apk add package" to install once the deployment finishes. This script is run as can be seen from the custom log statements but still i do not see the installed package. Even when is use apt-get it says "unable to lock administration directory"
Using a statically compiled binary is not an option for me since that has its own issues.
Thanks
For the Tomcat, Java SE and WildFly apps on App Service Linux, you can create a file at /home/startup.sh and use it to initialize the container in any way you want (Example: you can install the required packages using this script).
App Service Linux checks for the presence of /home/startup.sh at the time of startup. If it exists, it is executed. This provides web app developers with an extension point which can be used to perform necessary customization during startup, like installing necessary packages during container startup.
I think this is a common problem with Linux on Azure.
I recommend having a step back and consider one of the following options.
Run your application in a container that has all the dependencies
you are looking for.
Run your application on Linux VM IaaS instead
of Azure App Service (Linux),PaaS.
Run your application on Windows OS PaaS and add extension for your dependency.(Most likely you won't run into this problem when using Windows OS)
While I understand that none of them might be acceptable by you, but I have not found a solution for that problem in those specific circumstances.

How to install IIS in Windows EC2 using AWS CodeDeploy?

I need to deploy a .NET project on an EC2 instance running Windows, and in order for the code to run I need to make sure the instance has IIS installed.
This also needs to be automated (hence the need for CodeDeploy).
How can I install IIS and MS-SQL using CodeDeploy?
I'm a bit familiar with CodeBuild but I don't think it will particularly help me here. I'm using CodeBuild to build/compile the .NET application and put the output in S3. Now I need the next step which is taking that code and putting it on an EC2 running IIS and MS-SQL.
I would recommend to install IIS/MS-Sql from within UserData of the EC2 instance or use a Pre-baked (Golden) Image approach. Installing software via CodeDeploy is not recommended as such feature installation may take long time in Windows environment and is error prone.
An example UserData to install IIS on Windows is as follows:
<powershell>
Import-Module ServerManager
tzutil /s "AUS Eastern Standard Time"
Add-WindowsFeature Web-WebServer -includeAllSubFeature -logpath $env:temp\\Web-WebServer_feature.log
Add-WindowsFeature Web-Mgmt-Tools -includeAllSubFeature -logpath $env:temp\\Web-Mgmt-Tools_feature.log
</powershell>
Use CodeDeploy to Deploy your application artifacts and restart any service(s) if required. Deployment instructions for CodeDeploy are stored in appspec.yml file in the root of your source package. The syntax for a Windows version to deploy to IIS is detailed here [1].
References:
[1] https://docs.aws.amazon.com/codedeploy/latest/userguide/tutorials-windows-configure-content.html#tutorials-windows-configure-content-add-appspec-file

Why is the "Build an image" step failing for Docker on Visual Studio Online?

I'm trying to build a Docker image, which seems to build and run fine on my local machine, but it keeps failing with the following error:
2018-05-06T13:56:15.2331697Z failed to register layer: re-exec error: exit status 1: output: ProcessUtilityVMImage C:\ProgramData\docker\windowsfilter\3b555fe81a5123419e06c66652d9e73adbbb17b10f52ddd9f59da3b7fb87adab\UtilityVM: The system cannot find the path specified.
2018-05-06T13:56:15.2531044Z ##[error]C:\Program Files\Docker\docker.exe failed with return code: 1
It fails on the "Build an Image" step. I'm trying to use an Azure registry type.
I'm trying to set up Continuous Deployment using Visual Studio Online. I selected the Hosted 2017 build agent (but have tried other ones with no success there either).
My app is a .Net Core app. I think it's trying to use a Nano Server, and from what I read, that might be part of the problem (maybe the Hosted agent doesn't support the Nano Server).
All of these technologies (.NET Core, Docker, Nano Server) are new to me (and probably new to mostly everyone), so I'm limited in my knowledge about them and where to start troubleshooting.
Any ideas?
The step of the Docker file that it's failing on is this one
FROM microsoft/aspnetcore:2.0-nanoserver-1709 AS base
It is not supported on Hosted agent of VSTS, check this issue: Docker images based on nanoserver-1709 not building on hosted VS2017 agent

TFS 2017 CI with Gulp

I have just set up a TFS 2017 server and am trying to go through the CI tutorial at https://learn.microsoft.com/en-us/vsts/build-release/apps/nodejs/build-gulp?tabs=vsts but am having trouble on the Gulp task. I am getting the error "Not found node: null". I am using an ubuntu agent with the most recent versions of node, npm, and gulp installed. All the tasks are configured exactly as described in the tutorial.
The error usually means you have an environment issue , such as node couldn't captured by TFS build agent.
For the Default agent queue:
VSTS: Select Hosted VS2017. This is how you can use our pool of agents that have the software you need to build your app.
TFS: Select a queue that includes a Windows build agent.
Source Link
If you are working with linux build agent, you need to use windows build agent instead of ubuntu(linux build) agent.
If you are working with windows agent, make sure the node, npm, and gulp installed before TFS build agent configured, otherwise the new capability will not captured.
You need to reconfigure the build agent or restart VSO agent service. Besides make sure your working directory of Gulp task is getting set properly.
I ended up uninstalling and reinstalling nodejs and npm. I believe the problem was that TFS did not sense the node.js and npm capabilities because I originally installed them using nvm, so the second time around I installed using apt packages and everything worked fine.

Deploy NodeJS app to Azure from VS Code

Created simple nodejs app in VS Code (Linux). Also created NodeJS app in Azure. How to deploy app from VS Code to this Azure app now? AZ CLI installed. I've downloaded some MyApp.PublishSettings file however seems it used in VS not VS Code. What is the best way to deploy then with or without git (github)?
Local Git deployment from command line (or VS Code terminal):
git remote add azure https://<username>#<app_name>.scm.azurewebsites.net/<app_name>.git
git push azure master
If empty application already there use force flag:
git push azure master -f
Useful links deploying Bot Framework To Azure On Linux:
https://code.visualstudio.com/tutorials/nodejs-deployment/deploy-website
https://blog.botframework.com/2017/04/27/Deploying-Botframework-To-Azure-On-Linux/
P.S. Could be outdated since 2017.

Resources