image
Deploying the App

Contents

Introduction
1
Introduction
PREVIEW2m 59s
Section 3
10
Setup
3m 4s
Conclusion
13
Start course
Difficulty
Intermediate
Duration
52m
Students
487
Ratings
3.4/5
starstarstarstar-halfstar-border
Description

Over the last few years, Docker and software container systems have become the industry standard for packaging and deploying applications. A consequence of this trend has been the development of container orchestration systems like Kubernetes and Apache Mesos. Microsoft Azure has entered the space with its own comprehensive system orchestration and management system, Azure Service Fabric.

What exactly is the value-add for Service Fabric? How do we use it to solve container-related technical challenges? This course answers both of those questions and goes even further by covering a number of relevant software design concepts. From this course, you will learn what Service Fabric does, how to use it to deploy a real application, and how Service Fabric incorporates design patterns and structures such as the actor model and collections.

By the end of the course, you should be ready to work with a team using Azure Service Fabric to create a working application.

Learning Objectives

  • Use Azure Service Fabric to solve infrastructure orchestration challenges
  • Learn about software concepts relevant to Service Fabric, including collections, the actor model, and stateful vs stateless services
  • Deploy an application to a Service Fabric cluster

Intended Audience

  • People looking to build applications using Microsoft Azure
  • People interested in container orchestration systems

Prerequisites

  • General knowledge of IT architecture
  • General knowledge of software containers

Links

Transcript

To deploy our application using Service Fabric, we have to do two things. First, we have to create a Service Fabric cluster. And this is what provides the hardware, the resources, needed to run the application. Second, after we have the cluster, we need to install our application onto it, onto the cluster. 

Now, there are many ways to do this but in this example, we're going to use a shell script. So let's start with the first task. How do we go about creating a cluster? If you go back to your Azure Cloud Shell or Azure CLI if you're working on your local computer, you'll see that you already have the necessary tools installed. So we could go ahead and look here. We go back into our Cloud Shell and we should see that we have the code here in the Service Fabric directory and we want to look in the Linux directory and we wanna look at the container tutorial. That's where the relevant code is gonna be. We'll dig a little deeper in a second but when I say we have the relevant tools already installed, what am I referring to here? Specifically, it's a command-line tool known as sfctl.

This is the Service Fabric command-line tool that let's you create a cluster by passing in various arguments. So if you just do sfctl and hit enter, you'll see that it'll output, you know, submit information but it shows you that we already have this tool installed. So we're gonna do sfctl cluster create is gonna be our command. 

Now, there's a bit of a problem here. Even though we have the tool installed, we have code, there is an issue. If we try just running sfctl create from scratch on the command line, it's gonna be very messy because you have to actually pass in a lot of arguments. You have to pass in several flags about the hardware, about the environment, about resource groups and keys, and various things. So we don't wanna do that because that's a very error-prone process. It's likely that something will be wrong, we might have a typo, it's not the safe way to do it. 

So, the better way to do this is to create a script, is to create a Bash script that has all of our arguments written out, we can audit it, we can check it, we can put it into version control if we want. And then, we just run that Bash script. So that's the safe way to do it and that's how we're going to actually do it in this tutorial. 

So eventually the command will finish running, it'll take a few minutes and you'll know it succeeded when you see all of this output about your cluster. It'll spit out a lot of information here. And so, we're ready now to go about installing our application into the cluster. 

Now, actually, before we do that, there's one thing we need to take care of. We need to actually get the certificate so that we can securely connect to the cluster from our browser. This is an SSL certificate basically. And without it, we would only be able to connect from within the Service Fabric portal or through some other tunnel. But with the certificate, we can just go into our browser and see the app running. 

So, how do we do that? The exact instructions are a little varied by browser so we're not gonna go through every single browser, how to install a certificate that you've downloaded. So we'll include a link has a walkthrough for how to do the portion that is in the browser, the actual browser config (https://docs.microsoft.com/azure/service-fabric/service-fabric-quickstart-containers-linux#configure-your-environment). But for as far as the download portion goes, that is pretty easy to show you. 

So, we're just gonna refresh our cloud environment. It's been stacking up for a little while, sometimes just to refresh it. So we'll go into our containers directory, we'll go back into Linux. This should be the container tutorial and this is where we ran our install command, we see it here. And you'll notice that there's a bunch of new things here. There's this .pfx file and this .pem file. These are the names, you can see, reference the cluster we just created. 

So, what we want is this, the .pfx file. We want to download this from our Cloud Shell environment to our local computer. So how do we do that? Well, we have a button for it right here. You'll see there's a button for upload and download files. If we click on it, download, it's gonna just ask for the path to the file. So it wants the full path so we have to go from /home/ whatever to, you know, all the way down to this container tutorial director. So to get the full path, we can actually see it here appended. It's gonna be the home directory and then Service Fabric containers, Linux container tutorial. 

We can just go ahead and copy that and then it's gonna be that path slash this file name this .pfx file so we'll copy that and paste it in. And now we've got the full path here from the home directory. So we will copy that whole thing and then we'll go and click on download and then we should just paste that in and click download and it should just pop up. And we have click here to download your file, there it is. So we've got our file. 

Now we've got our certificate and the rest is pretty simple whether you use Firefox or Chrome or Microsoft, it shouldn't be too hard. 

Okay, so now that we have the browser certificate installed and ready to go, finally we're gonna go ahead and install our application. And, you know, as you can see before we do that we need a little bit more sanity checking here. In the portal, we went into resource groups just to make sure that everything came up all right. 

We should see here this ca737 resource group that we created. If we click on it, we can see the relevant resources. Here's the actual cluster, here's the key vault, load balance that was created, and some other elements here. So that's just another sanity check that things are working. 

Now, there's one small thing we have to do and actually we could've pre-optimized on this a little bit. In order to run the install command, we need to have the PEM file in the same directory. So that install script, we actually could have run it from the voting directory if we wanted to and it would have given us the PEM file in the right directory. But that, well, we didn't do instead we ran it one directory up. 

So what we're gonna just do is go ahead and copy this PEM file which is an important secret file. And we're gonna put it into the voting directory. 

Now, why are we putting it in the voting directory? Because that's where our install script is. We have to run this install.sh script in order to install the voting app and it is gonna need this .pem file. And also, we're gonna run a select command, that's also gonna need it. 

So, before we run the select command, I'll explain that in one second, I just wanna show you the script. It's actually really, really simple. It's a couple of commands here. Sorry, I'm just trying to make the window a little bigger. 

So, yeah, Bash script we're gonna set a couple of names for our app and the file path. We upload the application code, we select provision, and then application create. It's three sfctl commands with some echo statements to show what's going on. 

Now before we can run this command, we have to do sfctl select. We have to select the cluster so that that is already pre-configured for the command to use. And on that command, we can actually just get the code for it, the actual command from the documentation again. It's sfctl cluster select. So we'll copy it from here. And we'll make a couple of tweaks to it. 

Obviously we have a different name so, for example, our app is going to be ca737 and we are in east US so that should be fine. And our PEM file name is definitely gonna be different. It will have different numbers appended to it because I believe it's using the date so we wanna delete that and pass in the right PEM file for this command. It's in the same directory so we can just auto-complete ca737, that's the right PEM. 

We're adding a new verify flag just to make it go a little faster. We're not worried as much about the TLS stuff. So this should work. We can verify that we have the right cluster name here by clicking on that in case there's a difference here. There shouldn't be, what we see here https ca737 container test cluster.eastUS ca737 container test cluster .eastUS.cloudapp.azure on 19080. 

So that should be our select and we should be able to run that. Let's see if it works. And you'll get a little warning about the no verify but that looks good. And assuming everything is happy we should then be able to run our install command by just doing ./install and it'll upload our application file, same warning. And this will take a minute because it has to run a few commands. But once this is done, you'll be able to access your app from the browser and actually see the voting application work. So again, good job for making it this far.

About the Author
Students
15496
Courses
5

Jonathan Bethune is a senior technical consultant working with several companies including TopTal, BCG, and Instaclustr. He is an experienced devops specialist, data engineer, and software developer. Jonathan has spent years mastering the art of system automation with a variety of different cloud providers and tools. Before he became an engineer, Jonathan was a musician and teacher in New York City. Jonathan is based in Tokyo where he continues to work in technology and write for various publications in his free time.