HTML5 with .NET backend App, compatible with both standalone Windows and Azure? - c#

I need to design an HTML 5 responsive, and simple app that should work on both internal Win server and on Azure.Our Client wants to check out Azure but maybe later he will want this app to be on its own on premise servers. Our Developers are almost all .NET back ends, with basic knowledge in HTML 5, Javascript, Jquery, and bootstrap. We accepted the challenge because the project is tiny and interesting, the point is, is possible to have 1 project that can be deployed to azure or IIS with no problem? and what kind of project should we create? I think that a simple asp.net project with some web methods and js will do the job, but I don't know if it will work on azure too. Back n 2010 I did something that way but now I am not sure it's still valid
Important: the web application should be able to query oracle on premise server, via web service but not sure if take azure service bus or azure vpn

It depends on how you build your application. I have built applications in the past that works both on-premise and on Azure. As long as you don't access any Azure specific features, there's no problem to deploying the web application project to an on-premise IIS.
If you use Azure-specific features or services from Azure, such as Azure SQL DB, you have to built an on-premise version. In my case it was simple as changing the connection string and the rest was done by Entity Framework, but you can use an IoC container, such as Unity, to change your implementation based on the environment you're running on. If the Azure environment is available (check through RoleEnvironment.IsAvailable) you resolve the Azure-specific implementation of some features and if not the on-premise implementation. In most cases that are just a few dependencies, for example if you use a worker role on Azure and a Windows Service on-premise.

Related

Why does the official Microsoft tutorial have me push two copies of the same dotnet core app as the "frontend" and "backend"?

I'm pretty new to Azure, and I wanted to get familiar with using Azure AD auth as an authentication provider for a dotnet core web app.
I followed this tutorial: https://learn.microsoft.com/en-us/azure/app-service/tutorial-auth-aad?pivots=platform-linux
It worked as described, but I have to be missing something, because the way it's deployed doesn't make any sense to me.
The "starting point" tutorial code is this repo, here: https://github.com/Azure-Samples/dotnet-core-api
It's a simple dotnet core web app that hosts an Angular frontend. Through the course of the tutorial, you make some changes to get the "frontend" to talk to the "backend", and you add two remotes to your Git repo - frontend and backend - but they're on the same repo.
As I understand it, at the end of this tutorial, I have two nearly-identical Azure App Service instances running in my Azure resource group. They are both running the same code. Both include the full-stack application - both are hosting a Kestrel or HTTP.sys (or whatever) instance on port 443 at their respective .azurewebsites.net URL - both show my index.html page - but one is supposed to be the "frontend" and the other is supposed to be the "backend". The only thing different about the "frontend" and "backend" is that the "backend" has an identity provider configured, and the "frontend" has API permissions granted to it from the "frontend".
Is it really necessary to have the whole service running in both places? Is there a way to host the actual dotnet core API service as an App Service, host the HTML / JS / CSS separately as an Azure Static Page (or something similar), and still configure the identity provider? Or does it have to be like this? It seems like overkill, from a technical standpoint, as well as from a billing standpoint.
As #Caius Jard mentioned, we can include both of them in a single solution. We can actually use MVC Web Application in this case where we can create a frontend in view and write the actual code in control. If we are using a core application then we can create the backend and frontend in two environments such as Angular for Frontend and .Net core for Backend and integrate them.
REFERENCES:
Azure AD Authentication For MVC Web Application (c-sharpcorner.com)
Angular and .Net core - Azure AD authentication | The-worst.dev

Automatic azure deployment

We've developed a MVC application that uses a SQL database to store data. We chose the approach to have a separate web app in azure (customer.ourdomain.com) per customer, as well as a separate database per customer running on our SQL server. This database is pointed to by the MVC application in the web.config file.
I've also created a website where new customers can register to use / try our product. Now every time somebody registers for our product I want the following to happen:
Create an Azure web app with the name of the company / customer that registers
Create a new database including the tables and relationships that our application needs
Publish the stable release of our application to the web app in azure and configure the application to use the newly created database
I've managed to do the first step using Azure ARM templates and the second step using dacpac and the Azure API, but I don't know how to use TFS (or any other method) to publish a stable release and change the connection strings before publishing the application to the azure app. (I've not even managed to publish anything with C# code).
Is the approach I'm taking in general okay or should I take a different approach? What is the best way to publish a stable release to the web app and most importantly, change the connection string so the published version will connect to the new database?
If you get vsts to package up your stable release and upload it to blob storage, you can reference that web app as part of the ARM template deployment, ie. include the web app code deployment along with the web app service itself.
This page shows how it can be done. I think you can also get the web app and ARM template to pull a release from vsts (I'm pretty confident you can do it via GitHub) using the app service's source control integration/CD settings as well, but cant find any details on this.

How do I deploy an app with multiple components to Azure?

So my application is composed of a handful of separate .NET components that all run in Azure. To give you an idea of what's involved:
A main ASP.NET MVC5/Web API 2 REST service that runs as an Azure website (I think they renamed these to web apps?).
A SQL database that the main REST service uses.
Another internal Web API REST service that the main REST service talks to that runs as an Azure website.
An Azure storage table that the the internal Web API REST service uses.
3 scheduled jobs (just .NET exe's) that do work in the background and also talk to the main SQL database.
All that's running great in Azure right now. My problem is automating the deployment and configuration.
Right now it's all manual. I right-click and publish both web apps from Visual Studio. I build and FTP up the web jobs. The database and Azure storage already exist so I don't have to re-set them up.
But say something bad happens - a datacenter goes down or something. I'd like to be able spin up a new version of my app (with all those components) that is ready to go with minimal effort.
I'm pretty new to the world of Azure so I'm not sure where to start. What are my options?
You are looking to automating deployments in Azure. I recommend to use ElasticBox to solve it.
To achieve the automation you will need to create a box for every different service or component you need to deploy (a box is the abstraction unit that uses to define the installation and configuration of the deployment of a service or application in any cloud).
It's possible also to create boxes based on VM Instances, VM Roles, or Worker Roles and also automate the deploy of Microsoft SQL Servers. Let's say near every option offered by Azure.
Then with those boxes completed (that can be customized and reuse your legacy code from your previous manual installation), you can deploy the multiple vms with near no manual intervention, just one click or a command with some parameters.
A box includes the variables necessary for your deployment (you can set default values for those variables) and your legacy scripts (In this case probably PowerShell, but they could be bash, python, perl, java, or any other language)
When you deploy your boxes:
Creates a Cloud Service or VM in the location that you choose and with the Azure configuration that you preconfigured. It takes care of provision the vm in your Azure provider, or near any other cloud provider in the market.
Installs, configure files with your specified variables and execute your SQL or Web services that you have defined.
Other ways to interact with the service:
Jenkins' Plugin could be used to build a CI environment connecting your code updated or a Pull Request with automated deployments in Azure or any other public cloud.
Command line tool that enables to do VM deployments of your boxes and also you can manage your deployed vm instances with it.
Azure Resource Manager (ARM) is intended to solve exactly the issues you described.
The basic idea is that you use a JSON template to describe all your services. You can then give that template to ARM and it will create the services as defined in the template. If you want to make a change, instead of doing it imperatively (via powershell or manually in the portal) just update your template, pass it to ARM and it will make whatever changes are necessary to make the services match your template.
Some resources:
ARM talk at MS Ignite 2015
ARM template language reference
Quickstart templates on GitHub
Azure Resource Explorer - view ARM templates of existing resources
Resource Group Deployment Projects in Visual Studio
I think your looking for something to help you handel deploys to your windows Azure servers. If that is the case I recommend looking into Jenkins CI. There are many resources available online you can look into in terms of having Jenkins and Azure work together.

How to deploy a web application with WCF as a cloud service using Windows Azure Pack?

We want to develop a web application as a cloud service on windows Azure. The application has the following architecture:
This application was a simple line of business winforms application, where any customer could purchase and use it. Now our company decided to redesign it as a web application where many customers can work on it in the same time. The core application will stay the same, just some simple customizations, it does some simple tasks in the database and sending emails and other things.
Now, Our company decided that we need to use windows Azure to publish the web application as a could service. We don't need to use any of the Azure storage nor SQL Azure database services, instead we will use our datacenter's storages and database. We just need to deploy the application as a cloud service, and we don't know where to start. I couldn't understand how to use windows Azure cloud services in this application. So my questions are:
Is this architecture valid with windows Azure? And where would be the role of Windows Azure and its cloud services in this archticture?
We don't need to host the application on Microsoft datacenters, instead we need to use it in our datacenter, when I searched I found the Windows Azure Pack for Windows Server, so can we use it so that we can host it in our datacenter? Does we need any extra cost consideration to use it? Where to start to use in our application?
I found some posts and tutorials (like this one here in SO) saying that I just have to create a new Window Azure Project and add a WCF Service Web Role, copy the application files from the old Web Service then host the same as a web application. Is that true? Is windows Azure just involved in the deployment and it doesn't has any effects in the internal architecture of the application?
You can deploy both your UI and Service back-end to Azure Web Roles. If you have any remaining WinForms application, they still can connect to the Service back-end. I would recommend that you also deploy your database to Azure if possible to improve performance and reduce latency. You can either use Azure SQL Database or you can create a SQL Server VM.
There are various interesting options to deploy layered applications to Windows Azure. You can read more about it here. http://serena-yeoh.blogspot.com/2014/01/layered-applications-and-windows-azure.html
You can also checkout a simple sample here
http://cloudsample.codeplex.com

What are the limitations , if any , when hosting a WCF service on azure

I wrote a WCF service and I want to host it in azure. When I wrote the service , I didn't have in my mind that I am going to host it in azure.
Every application , even a WCF service , is using platform resources. When I say resource , I mean anything:
memory
CPU
File handle
Low level APIs (pinvoke)
Com objects.
sockets
.Net BCL API (Yep , I even consider this as a resource)
Databases
etc..etc.. (anything that is not the code i have written myself)
Hypothetical example : If the service , for example , logs to Drive 'H' , it may work on my computer(since I have drive 'H') , but it will probably won't work on the cloud. Same for Drive 'C' , or any drive letter , I don't even know how a file system is seen from the service perspective.
This is just one example.
Another hypothetical example : I can pinvoke from the service some winapi method in nt.dll , It will work on my computer. But i guess it won't work on the cloud.
My question is :
How can I know what kind of resources can be used on the cloud and how resources are used when writing to the cloud? What are the "rules" to follow? Also Is there any "Smart" Compiler that can ensure that my service is compatible with the cloud platform
I'll be glad to get any detailed explanation or a reference\book about this topic. I tried to find some info by googling but didn't find anything that cover it well enough.
Once i'll get the details i'll be able to make the nessecary porting to my service (if any needed at all).
The limitations depend on how you host your WCF Service:
Windows Azure Web Sites: This is a shared hosting model. If you deploy your WCF service in a web site you'll need to take that into account. This means you'll have limited access to disk, limited access to low level APIs, no way to use native libraries, ...
Windows Azure Web / Worker Roles (PAAS): Your application will be deployed in a Windows Server 2008 / 2012 VM. So if you want, you can leverage all functionalities you would use on a normal Virtual Machine (all "resources" you mention in your question). The only thing to keep in mind is that these virtual machines are non persisent (meaning all data you store on them could get lost) and that the load balancer is not sticky (could be an issue if you use WCF sessions). The fact that these machines are not persistent also means you cannot install a database server on them in a reliably way, but you can use an external database, like SQL Azure. The advantage of this solution is that the machines are maintained by the Fabric Controller, so you push your service package (the application) to Windows Azure, and the rest of the deployment is done for you.
Windows Azure Virtual Machines (IAAS): You get a machine like in Web / Worker Roles which allows you to use all "resources", but with even more control. The machines are persistent, meaning everything you store on them is persisted in Blob storage (if the machine crashes, you don't loose the data stored on the OS drive and data disks). This is the closest alternative to an on-premises deployment, but this also adds extra work. It will be up to you to manage deployments on all servers, to handle security updates, ... But in this case you could install your own database on a machine. Keep in mind that also here the load balancer is not sticky which could impact features like WCF session.
You can follow below mentioned Guidance for Using WCF in Windows Azure.
Deciding whether to run a WCF service in a web or worker role
WCF services can be hosted in either a web role or a worker role. Which type of role you decide to use depends on the type of WCF service you are writing
Running a WCF service in a web role
A WCF service that is set up for deployment to a Windows Azure web role uses the same setup and configuration as a WCF service hosted in IIS on on-premise servers.
Understanding WCF Security in Windows Azure
The security concerns for hosting a WCF service on Windows Azure is the same as those you encounter hosting the service in on-premise servers
Troubleshooting WCF in Windows Azure
You can troubleshoot performance issues for WCF services in Windows Azure using the same techniques that you use with WCF services hosted on-premise servers
For get more information check Guidance for Using WCF in Windows Azure Here
I hope this will help to you.

Categories

Resources