How to deploy Azure Fabric service on IIS? - .net-core

I have developed a Azure Service Fabric service .Net core 2.2 which contains a controller and some API methods inside it. I deployed the service on local cluster and its working fine. I am able to access the api endpoints.
But now I need to deploy it on local IIS too. I published the service project that contains my controller, and when I try to deploy it on local IIS as we usually do while deployment of other apps, I get an error "HTTP Error 500.0 - ANCM In-Process Handler Load Failure". I am googling for this and trying to find solution but no success yet.
Is there any particular setting or process that needs to be followed to deploy Azure Service Fabric service on IIS ? I am unable to figure out what I am missing.
Any suggestions or ideas?

When you create a Service Fabric service, the runtime need to talk to the Service Fabric System Services at startup. If you deploy it to IIS, it does not have a cluster to talk to.
If you want to make an API flexible to be hosted either on Service Fabric or IIS, you need to decouple the hosting logic from the API.
In this case, you can either create two different hosts, or:
in the host entry point, check if you are running inside SF, if yes you start the Service Fabric Service otherwise you start a self-hosted or IIS version.
There are quite a few questions in SO with examples like this, worth a search to check which one fits your needs.

Related

App Configuration service for on-prem dotnet core app

We have a dotnet core 3.1 console application. It is deployed to on-premise Windows server. There is some sensitive information that we would like to keep in Azure Key Vault. However, instead of accessing Key Vault directly, we would like to access it via App Configuration service.
https://learn.microsoft.com/en-us/azure/architecture/solution-ideas/articles/appconfig-key-vault
Above article mentions that any application can use Azure App Configuration (under Potential use cases).
Does "any" include application hosted outside of Azure? If so, can you share high level steps on how to access App Configuration service from dotnet core app that is not running in Azure.
it seems that any means any, looks like the steps remains the same as long as the connection string to config services work, i'll do some testing with quick start material and let you know..
Best!

How to deploy a solution with two projects to Azure App Service?

I am trying to minimize the cost of running my web app in Azure App Service. I have a Visual Studio 2017 solution with two Web Projects: Web and API (both .NET Core). The entire solution is part of a single GitHub Repo. Before adding the API project, the build and deployment to Azure App Service was automated. My goal is to deploy both projects under the same App Service (to minimize cost) with two subdomains (e.g. www.example.com and api.example.com) and keep everything automated.
Is this something that can be done? Can somebody please help me understand how this can be done? Can those settings be commited?
An Azure App Service Plan can contain multiple web apps. Normally when you use the Azure portal to connect it to source control, Kudu (the tool behind App Service Plans), will create a deployment script for that site.
In case you want to deploy two projects of a single solution (and git repo) to different Web Apps you have to do the following:
Create two web apps under the same App Service Plan
Connect both of them to the same git repo for automated deployments
Modify the deployment parameters
I'm going to suppose you know how to do the first two steps.
To modify the deployment parameters, you could either modify the deployment script by downloading it through Kudu and adapting it or, much simpler, configure it through the portal:
Go the App1 => Application Settings => Add setting PROJECT with value
<path>\<path-to-app1>.csproj
Go the App2 => Application Settings => Add setting PROJECT with value <path>\<path-to-app2>.csproj
Every time you push up a change, both web apps will receive an update, but they will deploy a different part to the web site.
More information can be found here (see last paragraph): https://github.com/projectkudu/kudu/wiki/Customizing-deployments

Publish asmx web service on azure

I have created an ASMX web service. i want to publish it on azure cloud. I have tried by creating Azure Cloud Project in Solution but i got an error Atleast One Web or Worker role is required. Any Help?
Please add new Web role and try again.

Deploy to an Azure WebRole without Visual Studio

Is there a way I can deploy my entire website/webapp to an Azure WebRole without the need of Visual Studio?
Context: We have a test environment where there's an IIS hosted web app where our testers test (of course). The thing is, we want to grab that exact tested web app folder and deploy it "as is" to a WebRole.
Please avoid commenting on our procedure, we have been looking at it and we will eventually change it if we have to, I just need a 'simple' yes(how)/no answer.
IIS Web Deploy can be used to package/migrate/restore IIS applications. It can be enabled while deploying a web role as described in this article and allows to update the web role with the application as deployed in your test environment.
Be aware that only single instance cloud services are supported and that in case of a maintenance operation by the fabric controller, your service will be rolled back to the state created by the initial azure package deployment. (There once was a tool for syncing between multi-instance web deployments but sadly that did not work out too well and is no longer supported. Do not attempt to use or rebuild it.)
Installing and Configuring Web Deploy shows the steps to get web deploy for your local testing IIS while articles on using web deploy like this one show examples for calling the tool.
Another option to evaluate are azure websites and git deployment. This could provide you with a documented and reproducible form of deployment that is not prone to unwanted rollbacks while allowing the service to scale to multiple instances. This option might not work out if the application it too tied to the web roles infrastructure or contains code not suitable for the more restricted web sites environment.
A third option to look at is using CSPack as presented in this article. You basically create a service definition and package up the webapp manually without building it in Visual Studio or TFS.
Yes - make sure you have enabled Remote Access on your webrole. Then copy your web app from your local IIS folder to F:\sitesroot\0 (NOTE - may be E:\sitesroot\0 on same web roles).
Yes, you can write a programmatic interface against Web Deploy from your C# code. If you're deploying to Azure Web Sites, you could also use the Windows Azure Management Libraries to spin up new web sites or clouand deploy them.

Switching between azure/on-prem specific assemblies at runtime or pre-build based on config

I have a wcf web service which could be deployed to azure or on-prem.
I am trying to have a common code base for both scenarios but with different web.config for each sceanrio.
The problem is that when the wcf service is deployed on azure it needs to talk to azure cache instance and if deployed on prem it will talk to windows app fabric cache server.
the code to talk to both remains the same because they are the same caching product essentially.
However - if the wcf service is going to talk to azure cache then the project should have a reference to the following assemblies:
Microsoft.ApplicationServer.Caching.Core.dll (1.0.4817.0)
Microsoft.WindowsFabric.Common.dll (1.0.5627.0)
Microsoft.ApplicationServer.Caching.Client.dll (1.0.4817.0)
Microsoft.WindowsFabric.Data.Common.dll
Microsoft.ApplicationServer.Caching.AzureCommon.dll
Microsoft.ApplicationServer.Caching.AzureClientHelper.dll
If the code has to talk to app fabric on prem then the following assemblies have to be referenced.
Microsoft.ApplicationServer.Caching.Core.dll (1.0.4632.0)
Microsoft.WindowsFabric.Common.dll (1.0.4619.0)
Microsoft.ApplicationServer.Caching.Client.dll (1.0.4632.0)
Microsoft.WindowsFabric.Data.Common.dll
I am looking for a solution so that I can keep the same code base (.cs files and .csproj) and with a configuration switch in web.config it should refer to the right assemblies,
for example if 'UseAzure = 1' in web.config then the azure cache client side dlls should be referenced and loaded and if 'UseAzure = 0' then AF on-Prem dlls should be loaded.
I am wondering if this is possible using run time C# code or via a visual studio pre/post build task.
I am open to any other ideas to acheive this.
Could someone confirm on the feasability of these two options and if so point me to some code which does something similar.

Resources