 Hello there. My name is Mani Ramaswamy, and I'm a Program Manager in the Azure Service Fabric team. When it comes to building your Cloud application, the two key areas that you need to really focus on are how to perform an application upgrade, and how do you monitor and diagnose your app? That is what I'm going to be talking about. So Service Fabric offers you this control called, it allows you to perform a zero downtime upgrade. This is for both stateless as well as stateful Service Fabric applications, which basically means that you might have a lot of clients that are connected to your Service Fabric application, and you can actually perform an application upgrade that is live and without taking down your application, and you can actually see your clients never having to get an error in response. So let's actually first take a look at how this actually works under the hood before I show you a demo. So here we have a Service Fabric application, version 1.0, which contains two microservices which are in the color red and in black, which is what is running across the Service Fabric cluster. Now we want to upgrade this to a version 2.0 of the same application, but with the major difference being the microservice that is showing up in black is being upgraded. So we just upgrade the microservice that is showing up in black to the one in green, which is version 2.0. So let's see how this progresses. So the first thing to note here is that Service Fabric application basically upgrade works one upgrade domain at a time. So the microservices that need to be upgraded are upgraded one at a time. Now, the other key thing that you might have noticed is I didn't change the red color. I only changed the microservice that was in black to green. So you only have to update your modified service. You don't have to upgrade or update every service that is packaged in your application. And once an upgrade domain has been upgraded successfully, Service Fabric rolls that upgrade to the next upgrade domain and so on until your entire application is upgraded. Now, the key here is if Service Fabric encounters something that is wrong as in some health checks that are failing or your notes are not coming back online, Service Fabric will automatically perform a rollback and rollback your application to the previous version that was working. Now, all this is controllable by you. You can set whatever health policies that you want, even to have manual intervention if something goes wrong. Now, let's actually take a look at a real demo of how this works in practice. To show you an upgrade, here I have a Visual Objects application that is already deployed to my cloud, to my cluster in Azure. And it's basically running a version of the application. And here is the application since the platform theme is really really intense. This is what you actually get. So as you can see that these pyramids are basically moving across the screen but they're not rotating around their axis. So the main change that I'm going to do when I upgrade this application is to make the pyramids rotate around their axis in addition to moving across the screen. So let's hop on to Visual Studio to see what kind of code changes we are talking about. So the code change we are actually talking about is not very complex. Actually just, well, for me, since I'm just on commenting this and the method takes care of the rest is basically on commenting the state.move to true to commenting out the state.move false, which basically means that the objects start rotating around their axis. Now I need to rebuild this particular service that I upgraded by just using Visual Studio and rebuilding it and followed that by packaging your application. Now, before I show you how to do this in PowerShell, let me just show you a quick snippet of how to do this in Visual Studio. In Visual Studio, you can actually make an upgrade very easy by just clicking on publish and it'll bring you an UI and you provide the connection in point and you can provide your upgrade settings as well through Visual Studio and then you can actually change your manifest versions. So you can actually say your application version is too old. This is, these are the services that you're upgrading and so on. And then you can save and then publish. This will basically take care of the upgrade for you. But in this video, I'm going to show you how to do this through PowerShell in case you want to have a little more control on how the upgrade progresses. So here essentially is the PowerShell scripts that you need to be familiar with if you wanted to do it through PowerShell. So there are four commands. One is you need to copy your service fabric application package. So this basically copies your application package that is in the Visual Studio slash release, Visual Studio application folder slash release and you place it in the cloud image store and then you register your application type. And if you haven't deployed an application yet, you want to start an instance of the application. You can do new service fabric application and provide it with the application name, type and version and it'll instantiate an application for you. Now, once you're upgrading after you have rebuilt you still need to copy your latest application package which is your version two of your application package to, you can save it in the same location but it's always better to save it in a different location in image store. So I just named it underscore V2. You register the application type with the updated version and then you basically just call the start service fabric application upgrade. So I'm just going to start service fabric application upgrade at this point because I've done the other steps. As you can see, I've done the other steps and so I'm just going to start the service fabric application upgrade and you will actually see it progress. Now, you can get the application upgrade by looking at PowerShell and typing service fabric application upgrade and you can provide the name of the application. And this will keep telling you what is the status of the application. As I mentioned, it does the upgrade one upgrade domain at a time. So the first upgrade domain is in progress and the other is appending. But a more fun way of looking at it would be through service fabric explorer where you could actually click on applications and you can actually tell you there is one upgrade that is in progress. And it's basically telling you that the first upgrade domain is being upgraded and it will roll forward that to the next upgrade domain as it succeeds. Now let's see how the visual objects actually look like. So originally, all of them shouldn't be rotating around their axis and now the change that we made was to have these objects rotate around their axis. As soon as an upgrade domain completes, you will see some of these objects actually start to rotate around their axis and once that is successful and it passes the health metrics, then it'll roll over to the second upgrade domain and upgrade those objects there. So we'll just give it a minute as the upgrade rolls over. So it looks like this pyramid might actually be getting upgraded and see it got upgraded and it's actually now starting to rotate around its axis and so did this one. So obviously, a couple of upgrade domains may have been completed. You can of course go back to Silver Fabric Explorer and you can refresh to see how many upgrades have been completed. Well, it looks like one upgrade domain has been completed and the others are still in progress. And in a while, what you're going to see is all of them will eventually get upgraded as it meets the health criterion and it'll roll forward through all the upgrade domains. Now you can always check it through PowerShell as well, as I'm assured earlier, by using the GetServiceFabricApplicationUpgrade command and provide it with the application name. And you can see that it's actually showing now three upgrade domains are completed. So now you can also see this in the ServiceFabric Explorer. Now it shows that four upgrade domains have actually completed the upgrade, earlier it was three and so just one upgrade domain actually remains. And most of the pyramids would have started rotating around their access at this point. So that's it for demoing the ServiceFabricApplicationUpgrade. ServiceFabric offers you a lot of powerful monitoring capabilities. If you write your app using the actor or the services programming model, ServiceFabric already monitors and actually collects a lot of information so you can monitor your application. It's also very easy to enhance your application by adding custom application metrics. The same applies for health. ServiceFabric runtime provides a lot of built-in health metrics that you can actually use and again, you can extend this as you please. And all of this is based on ETW. So that makes it very easy for you to extend it and to basically plumb it through whichever pipeline that you want. Now let's take a minute and talk about the diagnostic capabilities that are offered in ServiceFabric. As you know, we never get caught wrong. We never write anything with bugs in them. Yeah, I know I'm kidding. In order to kind of help diagnose your application and troubleshoot what went wrong in your live service, ServiceFabric again offers you a lot of powerful primitives. It provides a variety of system optics that are built in so all the important events such as app creation, deployment, upgrades are always locked. It also provides repair suggestions in case something goes wrong. And again, all of this is ETW based. So again, you can add your custom ETW events to have enhanced monitoring capabilities or enhanced diagnostic capabilities that are specific to your application. And with ETW, the same code that runs in your developer box is the same code that runs in production clusters in Azure. And finally, because again, this is ETW based, you can use the Visual Studio diagnostic events viewer which is built in VS whenever you actually do a debugging of your application or you can use Windows Azure diagnostics and operational insights or you can even plug in whatever your preferred tools are Kibana, Elasticsearch and more. And now let's actually take a look at how this is plumbed through operational insights with a real application. So one of the key things is to be able to monitor and diagnose your app. So in this particular case, I have hooked up my cluster to report events to operational insights. And I have been deploying my application to that cluster where the ops insights and the ETW events are collected and sent to ops insights. So let's actually go into operational insights portal and in Azure, and you'll actually see that my applications and my system has been reporting events to operational insights. So you can see that I've been generating a lot of events because I set up the cluster and I've also set it up to report operational events in addition to my actor and services events. So if I click on my services events, you'll actually find that, you know, I've been doing a lot with visual objects obviously and I can see a lot of visual objects related events. So you can look at things like, you know, whether an upgrade is happening, whether, you know, something else is going on, when this run is called, et cetera. So I've been collecting a lot of events to make sure that my application is performing as expected. So this shows you quickly how easy it is to actually get your application to report events to ops insights. The key here is, you know, when you create a service fabric application, it's plugged into the event source library. So, you know, you have a service event source file that comes up when you actually start a new application. So you can, it is already inbuilt and you just have to update it to whatever custom events that you need for it to flow through to ops insights. Now, one other thing I want to show you is the visual studio diagnostics tool. So let's actually start a quick, you know, quick simple template application. Let's start the cloud service fabric application and I'm just going to call it application three. And let's make this a stateful or stateful act of service. Now, what you'll find is when I actually do F5, you can, you'll also see that it'll actually bring up the visual studio diagnostic tools, which allows you to monitor the same events that you just saw. You can actually see it on your visual studio screen as well. Let me just close this. And, you know, like whenever you start a new service fabric application, you will actually find a lot of helpful documentation and videos that will help you get started as well. Now, as I mentioned, you have the event source set up for both actors and services. So, you know, you will always find that it's plugged in. And now if I were to do nothing, but just say start and just diagnosis application, you will find that visual studio automatically brings up the diagnostic viewer in a second. So, you can basically use the visual studio diagnostic viewer in order to debug your application. And as I showed, like you can pump these events into something like ops insights or, you know, any other platforms, any other tools that you wish like elk and mind that for monitoring your application. And that tends to the ops insight demo part of this video. So now that you've seen those demos, you know how to perform a service fabric application upgrade and how to monitor and diagnose your service fabric application. Now, here are some related content that you can go and learn a lot more about service fabric and how to build an application and use the diagnostic capabilities and the upgrade capabilities that the platform provides. I will look forward to hearing from you. Have a great day.