I have create a ServiceStack console application that works great, but of course, I have to leave it running after triggering it from a command prompt. I want to run this as a Windows Service.
I'm reviewing this wiki page which states that you can run SS as a Windows Service.
https://github.com/ServiceStack/ServiceStack/wiki/Self-hosting
I was not totally clear on how to do this. This StarterTemplate is referenced from 2 years ago. Do I clone this project and then copy my code into it?
https://github.com/ServiceStack/ServiceStack.Examples/tree/master/src/StarterTemplates/WinServiceAppHost
The easiest way is to create a ServiceStack Windows Service Empty project in ServiceStackVS VS.NET Extension.
Otherwise you can clone the WinService project, and create a new Windows Service project from Visual Studio and copy the approach in Program.cs.
A more recent ServiceStack Windows Service project is the Razor Rockstars website running in a Windows Service Host, the template of which was based on the ServiceStack.Examples Starter template.
I use topshelf to run a servicestack console app as a windows service. It works really well for me. https://github.com/Topshelf/Topshelf
Related
Trying to run locally a Web MVC application using Docker. Application compiles and runs fine when Set as StartUp Project outside of the docker-compose project but fails when docker-compose is Set as StartUp Project during the build when it comes to Target DockerGetServiceReferences: with
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets(195,5): error : The given path's format is not supported.
I have added the docker-compose through Visual Studio 2017 to an existing application as described here:
How to containerize the .NET Framework web apps with Windows Containers and Docker
I appreciate this might be quite vague so if there are any more details I could provide please let me know.
EDIT:
Adding docker-compose to just default MVC template in a new project works fine so the problem seems to be with the legacy solution. Also noticed I can't navigate docker-compose project General Properties, I get the URI formats are not supported popup error
EDIT:
Adding a brand new MVC project from the template to the solution without any references to other projects also generates the error. Could this indicate that the problem might be somewhere on the solution level?
EDIT:
I have created a new Solution file and started to migrate all the projects. This way I am successfully able to compose docker image. Once I am finished migrating all of the project I will do a comparison on .sln files and try to see what is different.
I have several micro services that I would like to dockerized them. Is it better to build them in a self-hosted console application or build asp.net web application?
Which one is faster?
My MicroServices are only simple Web Api.
Just gonna give you my experience on this, not necessarily a 'complete answer':
If you create a .NET Core WEB API in Visual Studio and 'Add Docker support', you can directly deploy them to regular AppServices (specify 'Linux' as the operating system when you CREATE the AppService).
The Visual Studio wizard will automatically setup the container registry for your images, and configure the appservice to deploy whenever there's a new tag for your image.
I've also migrated this same Web API to deploy to a Windows AppService without docker, we didn't need to change any of the code, just deploy it without docker as a regular web app.
Which means if you build this as a .NET CORE 2 Web API you can deploy the same code to either a Linux Appservice using Docker or to a regular Appservice.
If you're planning to use anything different than AppServices tho, you might want to check Container services or Service Fabric, which IIRC is more expensive (would make sense if you need to scale this massively)
I am using VS 2017 15.6.4 which is the latest version. I have a single solution that has three web projects in it:
Solution:
Web Project 1
Web Project 2
Web Project 3
I would like to add Docker support so that all the web projects end up in a single container running IIS with the following IIS site structure:
Root Site (Web Project 1)
Admin Virtual Application (Web Project 2)
Campaign Virtual Application (Web Project 3)
Is there a way to accomplish this in Visual Studio 2017? When I add Docker support it seems to be on a project by project basis. I can run each project in its own container with no issues. Will I be forced to do this outside of Visual Studio?
I had a similar question and found the following helpful. Make sure you have Docker CE installed on your machine, along with VS2017 with Docker support. In VS2017, when you do "Add->Docker Support", it should automatically include the docker-compose.yml file at the root of your solution.
https://learn.microsoft.com/en-us/dotnet/standard/microservices-architecture/multi-container-microservice-net-applications/multi-container-applications-docker-compose#step4_define_svcs_in_docker_compose_yml
There is also a sample application posted on github, linked below. Note that this follows .Net Core v2.1. I'm assuming you are using .net core and if so, note that v2.0 is end of life later this year so you should consider moving to v2.1
https://github.com/dotnet-architecture/eShopOnContainers
The github project above also has links to some free books talking more on docker and .net core. They helped me out a lot!
In our current project we develop an ASP.net MVC application hosted in an docker (Docker Desktop for Windows) container using the windows server core image (https://hub.docker.com/r/microsoft/windowsservercore/). Everything is working well but now we would like to use the Windows Identify Foundation (WIF) for authentication with an ADFS.
Unfortunately, the Windows Server Core image for docker does not support the WIF feature and it cannot be installed.
Does someone have an idea how to use the WIF inside of a docker container and/or experience with installing the feature in this image?
Is their an alternative image with the feature enabled?
Similar topics without docker such as:
https://support.microsoft.com/en-us/help/3044149/you-can-t-install-windows-identity-foundation-in-windows-core
https://blogs.technet.microsoft.com/server_core/2012/05/09/configuring-the-minimal-server-interface/
Did not help.
I know this is an old question, but I recently ran into the same problem and wanted to share the resolution I was able to come up with. In my case, I was working with a legacy software solution that referenced "Microsoft.IdentityModel.dll" (installed by WIF), and it was not as easy to just switch it out to something else.
I installed WIF on my laptop (Windows 10) and then added the file to my docker image
C:\Program Files\Reference Assemblies\Microsoft\Windows Identity Foundation\v3.5\Microsoft.IdentityModel.dll
Then, add a PowerShell script to your DOCKERFILE to install that assembly into the GAC manually. Here's a good blog post showing how to do that as well:
https://www.andrewcbancroft.com/2015/12/16/using-powershell-to-install-a-dll-into-the-gac/
Hope it helps!
We could solve our problems with OWIN.
Bas Lijten posted a nice tutorial on this:
http://blog.baslijten.com/configure-claims-based-web-applications-using-owin-wsfederation-middleware/
We configured the usage of WS-Fed with Owin but did not use an Embedded STS. Instead we created a standalone identityserver instance to test the ADFS integration.
On GitHub you can find an example for such an identity server configuration:
https://github.com/IdentityServer/IdentityServer3.Samples/tree/master/source/SelfHost%20(InMem%20with%20WS-Fed)
In previous versions of .Net, there were some different methods of creating a project that could run as a console app or be installed as a service.
Things like TopShelf or other approaches like: .NET console application as Windows service
This is a nice convenience for development and later deployment. I put together a vNext console app using a similar approach to the accepted answer here: .NET console application as Windows service.
The issue is that vNext runs things in a different way. If you create output, it no longer gives you an exe to install. Instead you get a nuget package and a .cmd file that will tell dnx to host your application. The command file looks like:
dnx --appbase "$(dirname $0)" Microsoft.Framework.ApplicationHost My.vNext.Service $#
So my question is: Is there a way to install this thing as a Windows service given the new console application approach?