How to install IIS in Windows EC2 using AWS CodeDeploy? - iis

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

Related

Elastic Beanstalk Can't Deploy my ASP Net Core application on Linux

I've got a basic ASP Net Core application, developed on Windows, which I'm trying to deploy into an Elastic Beanstalk linux environment.
When I deploy, I get the following error:
2020/12/02 23:47:10.550207 [ERROR] An error occurred during execution of command
[app-deploy] - [CheckProcfileForDotNetCoreApplication]. Stop running the command.
Error: there is no .runtimeconfig.json file for your single application.
Please provide a valid application
The problem is, there is a *.runtimeconfig.json file in my deployed .zip file!
The structure of my zip file is loosly:
./Config/configs.xml
./Config/secrets.xml
...tons of .dll & .so files
PublicWeb.dll
PublicWeb.runtimeconfig.json
So I'm mystified as to what the problem is.
So I finally fixed it, by following these steps:
I was on .NET 2.1; so I upgraded to .NET 3.1 by following the migration guide.
I created a Debian image on WSL 2, git cloned my repo into it
Then I ran dotnet deploy from here & uploaded this artifact.
I'll note that the zip artifact was much smaller when built on linux for linux.

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.

NodeJS App Deployment via Azure DevOps 32bit issue

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!

msdeploy (Web deploy) installation in a container

I try to containerize a third party application running on IIS and Windows server. To do that, they supply to me a powershell script which is using Web deploy 3.
My problem is I can't install it, I always have this error code :
MSI install return value for product 'Web Deploy 3.6 ... is '1603'
The version 2 is installing though, but it's the version 3 which is required. I've also tried to install it with chocolatey, but I have the exact same error.
Here the part of the Dockerfile causing troubles :
FROM microsoft/windowsservercore-insider:10.0.17093.1000
[...]
# Register dll (the web say this can solve the error)
RUN regsvr32.exe %windir%\syswow64\vbscript.dll /s
# Copy The msi installer for web deploy 3.6
COPY webdeploy.msi C:\\Temp\\webdeploy.msi
WORKDIR C:\\Temp
# Install all webdeploy features
RUN msiexec /i webdeploy.msi LicenseAccepted="0" ADDLOCAL=ALL /quiet /qn /passive /norestart
Please do note I'am using the insider version because I need the MSMQ feature which is not released yet (It's a proof of concept).
Is there any requirement needed by webdeploy that I don't know and which is missing in the container version ?
It seems there is a bug in the preview build (as mentioned by #Gregory Suvalian). Using the last one (17623) seems to correct the problem.

Jenkins deployment from linux server to windows server

In company i have 3 servers, 2 linux servers and 1 windows server. I build .war on Linux server and i want to deploy it on second linux and windows server, for linux i use deploy plugin and it doesn't support version of tomcat8, and also it doesn't have option deploy war on windows server.
So my idea is to deploy war to samba directory then use copy script to obtain .war file. For windows i can use samba folder and in tomcat configuration use a deploy Application from a Local Path. Is there some more gentle solution of this problem ? If there some risk from using that solution ?
Edit:
In case when I try to use mounted directory, i use docBase="//ip/directory" and path="directory" i obtain error with The main resource set specified [\ip\directory] is not valid. I'm curious is even possible to do this ?
So if someone will face the same problem that is the solution:
On Jenkins server install plugin to execute shell scripts. That allow us to run cURL command.
To deploy .war on Windows server use command with cURL, example:
curl -T /var/lib/jenkins/jobs/(Path to war ) http://user:password#ip:port/manager/text/deploy?path=/(nameOfWar)&update=true
Also add role manager-script to your Tomcat user.
For deploy on Linux servers I use plugin Deploy war/ear to a container. So it's all in Jenkins and Tomcat.

Resources