Web App deployment to AWS and Azure

As promised, hereby the first instalment of the AWS vs Azure blog post saga, again I’m trying to remain impartial throughout.

What I intend to outline is at this stage is the show to get started deploying a new application to AWS and to Azure from within Visual Studio. I’m sure there are those of you that are shouting, “.NET, Visual Studio, Azure? Of course Azure will do it better!!!” however rest assured this is only the first of a few posts related to Azure App Service and AWS elastic beanstalk and AWS doesn’t fair all that badly.

Sample Application

The sample application in this case is just a File/New ASP MVC5 project using .net 4..6.1, I’m only hitting the home page as a test and not worrying about databases for now (databases will make another interesting series of blog posts!).

AWS Elastic Beanstalk

AWS has a AWS Toolkit plugin for Visual Studio, this allows you to view and manipulate AWS resources

image

It also lets you Publish Applications to AWS by right clicking on the solution and choosing “Publish to AWS”

image

 

Once you choose this option you’ll be presented with a dialog that lets you choose your environment or create a new one.
image

 

If you don’t already have one, lets create one, you will choose a name for the environment

image

 

Next you choose your instance size (the underlying VM size, or any custom Amazon Machine Image you’ve created previously), other options of interest are, use non-default VPC, this is basically the network you’ll be running on, all AWS accounts get a default VPC per region (and if you delete it you’ll need to contact AWS to get it back!). The option of single instance environment is selected here as this is just a test. If i wasn’t running in single instance mode, I would be able to Enable Rolling Deployment to keep my app running while it gets updated (more about that here: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.rollingupdates.html)

image

 

Lastly we choose the application settings, I’m just deploying a .net 4 runtime debug application.

image

Once you review and finish, you can see your application start deploying on the portal

image

Once it’s finished which can take a few minutes after the upload you should see the Health go Green and you can access your application

image
image

 

Note: If you’re following along and wish to stop this ElasticBeanstalk environment to minimize costs/free tier bandwidth, then please ensure to terminate it from the ElasticBeanstalk section of the console, Stopping the underlying EC2 instance will only serve to signal the autoscaling group it belongs to, to start a new instance and restore the health of this application.

Azure App Service

Now lets deploy this same application to azure. Right click on solution explorer and choose Publish

image

 

Choose to Azure

image

 

Like AWS where we chose a server environment we need to choose an app hosting plan, with Azure you can sign up for a free trial, if you have a subscription you can choose to deploy a free cloud app (you get 10 free per region, there are some limitations which we are not concerned with just now).

image

 

After creating this new hosting plan we arrive back at the publish dialog

imageimage

Visual Studio then starts the publish task and opens the application in your default Visual Studio specified web browser.

image

You can also see your new application seeding life in the Azure portal http://portal.azure.com

image

 

Summary

So in this blog post I’ve run through how to deploy applications to PaaS offerings on AWS and Azure, in the next post I’m going to drill down and and do some more comparing and contrasting of these two applications, stay tuned!

AWS or AZURE

History

So way back circa 2008 I registered for AWS free tier, now back then I was working in a different industry that didn’t have much need for ‘the cloud’ I played with a few linux vm’s during that year but nothing came of it and my trial expired.

Fast forward two years and Azure was born at least in public,, I was immediately sold and was all-in. I’ve used abused and consulted on more Azure projects than I can remember and anytime the subject of AWS came up I dismissed it as a inferior pioneer on cloud tech, I mean just look at the console it’s offending to the eye is it not?

Fast forward another two years and I found myself while heavily swallowing the PAAS cool-aid recommending AWS over Azure to a client, why? Simply because AWS have a managed offering for Oracle and that particular client did not have the knowledge or appetite to manage their own oracle server.

This did open my eye that there might be a bit more to AWS than an ugly console, an opportunity presented itself to become AWS certified and I jumped at it, now as I write this article I can put this lovely logo Solutions-Architect-Associateon my business card.

 

 

 

Learning’s

So what have I learned about AWS in in my quest for certification? Well the console is not nearly as offending as I once believed it to be, in fact I think it’s more practical than that sexy looking new Azure portal, it’s faster to get things done in than constantly sliding those Azure portal blades around the place that’s for sure. As for feature parity, for the most part both platforms tend to support the same features in the general sense but once you drill down differences do start to emerge.

I’ve also decided it about high time that I also get certified in Azure, (underway), this should give me the street cred I need for what I’m going to try achieve and hopefully my findings be as impartial as possible.

Cloud Wars

Starting from my next blog post I’m going to start comparing features on both platforms and outline the pros and cons of each… Stay tuned to what should be a very interesting blog series. Obviously the topics are vast, so, if anyone has any requests please send me an email: b at briankeating.net.

IE 11 Disassembly

So I’ve been looking at an issue for a client today where by an application working perfectly well on most browsers was failing on internet explorer 11. Users were presented with the following error:

imageI think we can all agree that it’s not very helpful.

 

The problem was this particular application has a massive code base, so it was hard to identify where to start given no other information was furnished by IE.

Assembly

In order to gain insight in what was failing I pressed the Debug button and let Visual Studio 2015 grab as much information as it could from the Microsoft Symbol servers only to be presented with the following:

image

 

Reading between the lines

Now I’m not an assembly man, and i say that at the detriment of a future role that has it as a nice to have, I’d rather gouge my eyes out than mess with assembly, that said, looking at the assembly above it it was clear that the issue was related to style sheets / css.

This allowed be me to narrow in on the offending code, and I quickly seen that the following line was causing the problem:

image[17]

 

It appears IE11 doesn’t like this, the solution for my client was to render the correct css serverside and now it’s working perfectly well for them.

Heading on nearly 20 years into my professional IT career I can honestly admit that this is the first time assembly saved my bacon! 

(Smilebut I’d still rather go blind )

A web app in minutes, java and .net

In this post I show you how to generate a shell for a web applications in both Java and .NET, while they are not directly a one to one mapping I think some of you will find this interesting should you have never created a web application on either stack or perhaps just one of the below mentioned.
I’ll let the videos speak for themselves.

Java

 

.Net

 

Follow up

I did promise to dissect both projects however I ran out of time,

I’ll leave it to you to pick your tech stack of choice and if you have any questions just ask below and I’ll explain in more detail if necessary.

WebAPI OData DTO

So I’ve started using OData in anger and pretty much immediately stumbled on a problem when using Data Transfer Objects (DTOs). This post explains that problem and the solution.

 

Problem

The following error is encountered when trying to access the exposed entity by key:

No routing convention was found to select an action for the OData path with template '~/entityset/key'.","type":""

 

image

 

Cause Code

OData configuration

Here I show the simple entity I’m exposing

image

 

Timesheet Controller

Here you can see that the underlying timesheets are just projected using Automapper to their DTO counterparts

image

 

Automapper config

Here I show the automapper configuration (not that it’s makes any difference to the problem encountered)

image

 

Solution

To fix this problem I needed to set the EntityType.Name property on my OData entity type.

image

 

And thereafter, success!

image

IntelliJ Application Servers Greyed Out

If you ever come across the problem of the IntelliJ Application Servers menu greyed out like this:

image

This is simply because you need at least one Run Configuration.

I’m using JBoss just now so here’s what I do to add a run config:

image
image

 

image

Once this is done you can now see your application servers tools window menu item becomes enabled.

image  image

Not accepted here

and it's not because I'm Irish ;-)

ODataController - 406

So I’m working on a project that returns some entities from an OData endpoint, I wanted to remove the unnecessary parts of my entities so I created some DTO’s (which in itself is a good idea btw). The screenshot below shows the changes, I’m now returning a TimeSheetDto list (previously just a TimeSheet list) and I’m just projecting (using automapper) the Timesheets from my database into these DTO’s .

image

 

However when I test said entities I see nothing come back in my browser, nada,zilch,zippo… so what is happening?
Well I fired up fiddler and saw that I was getting a HTTP status code of 406, but why?
It worked before and I changed nothing…. oh wait!….

Configure OData entities

You know that message that gets scaffolded with new OData end points!? We’ll it explicitly tells us what entities are to be considered, so with a quick addition of my Dto Suffix in my OData config I’m back in action.

image

Azure, Sql User invalid from Azure Website

Problem

I was faced with a problem this morning that took me a good 30 minutes to figure out..

I had created a website and associated SQL database. However I changed said database as part of some development work. The problem was that even though my publish profile was overriding the Release Connection String with my new database it was getting ignored!

image

 

I knew that the connection string I was supplying was correct as I could log in with Visual Studio and SSMS.

Cause:

The reason is that the website had already an connection string (under the Configure tab) and this was taking preference. The reason this is here is that one does not have to store the Azure connection string in the publish profile which is quite nice, same goes for a lot of other Azure features.

image

 

Solution

I removed same and then it works. (Fixing it is also another option but this code is in a private git repository so it’s not a concern for me just now).

Tech of the week

Appears to be the story of my life lately, just as I get excited and proficient on one stack I get side tracked with something else. The latest stack I’m playing with is the Ionic2 framework, but first some history.

 

UX Stacks

I’ve written UX applications in many different way in the past

  • java swing (albeit i’d never put this on my resume as I can’t recall a single bit of that application i helped a student friend with so many years ago)
  • MFC – Oh the pain
  • ATL/WTL – Actually i quite like this back in the old C++ days when men were men.
  • C# Windows forms – Spent years on this stack and if you’re happy with battleship grey it’s still quite RAD
  • WPF/Silverlight – Wrote quite a few applications in this, probably wouldn’t call myself an expert but I can xaml like the next guy
  • MVC3+ – Have written and still support a quite a few MVC applications it was the bridge that finally moved me heavily to web client side tech.
  • Objective-C/XCode – A handful of iPhone applications, it’s ok, language is a little weird yes but use it for a week read a few books/material and you’ll make a good stab at it.
  • Xamarin – A nice approach for writing mobile apps in  c#, problem is you still need to use the native designers (yes i know about xamarin forms.. are we really going to talk about that?)
  • Web tech, My transition to the web was a natural progression that leveraged things I’d learned with other frameworks, e.g Knockout was familiar from wpf data binding, angular has somewhat a familiarity to MVC

Ionic2

So what is Ionic2? In short it’s a framework for writing mobile (and progressive) apps. As you’ve seen above I’ve already ways of writing mobile apps, So why something new? Why not! in this world – always be learning!

In my case there were some more compelling reasons,  see for the last year I was an architect and hands on developer for a new web application using angularjs v1 sass, typescript and a tonne of wonderful libraries. Ionic2 is built around the same stacks, applications use angular2, html5, typescript, saas, gulp etc, the list goes on and on. Apparently I’m finding my home in this world, in fact if i was to write a greenfield desktop application I’d seriously consider writing it with html tech and framing with Atom/Electron.

Sample app

image_thumb2 Taking the application on the left as an example,
I was to create this screen in a few hours, sure i’s not the prettiest and contrasts are high, but the point is that from a blank canvas it only took a few hours to design and implement this screen using Ionic2 and web technologies. I’m a little spoiled as I can somewhat ignore the stubborn elephant in the room *CSS*. i’m targeting the latest devices so I’m getting to use flexbox for layout , css3 transitions etc.

I’m seriously convinced that when it comes to writing general purpose mobile applications Ionic2 will be hard to beat.

I know if i was to write the same screen in xcode/android studio it would take me a lot longer to implement this design.

Check out Ionic2 for yourself you won’t regret it.