Transform business-critical .NET apps with containers and Azure | B100
Hi, I'm, James Thor Devon I'm a senior software development, engineer with our commercial software engineering team I'm really, excited to be here today to talk to you about transforming. Your business critical dotnet. Applications, with, containers, and Microsoft. Azure, service, fabric. Today. We're going to talk about the. Service fabric platform and see, how we can actually containerize. And move, our existing. Applications, in this case a web, forms application, to, the, service fabric platform we'll take a look at the, different, the. Different. Capabilities. That, service fabric platform brings to us and such. As scaling rolling, deployments, and then. We're going to take a look at monitoring. So, in this distributed, world monitoring's. Can become incredibly important for us to determine. What, is happening, inside our application so we'll take a look at the different options we have there and then we'll take a look at how we can take advantage, of asher's, global. Scale to. Introduce. Fault, tolerance, to our application, after. That, we'll take a look at how we'll actually introduce, new functionality, to our existing application, using, service fabrics platform, and, the. Programming. Models that it brings, to us. Introduction, to service fabric and a place where many of us have already been so. We have a VM, and an. Existing service it's running and things are great here. Things. Are so good that we're actually our. Customers, are demanding that we grow, and scale our application, so we take our application, we. Scale. It out we added another VM, we, put a load balancer in front of that and then, we add a few more VMs, our. Application is now up and running and things are great so. Great that they asked us to have, they. Our customers asked us to have another application. So. We take that application, and we. Look, at our existing, infrastructure.
And We say as good engineers we want to say let's, reuse some of the stuff we have so we run our service out there. Next. Our, service our. Business is growing so much that. We, want to, start. To take, some do, we need some new internal, applications, to work with and so we take those applications, and we look and we run them out on some of these VMs that we have and then. We're enjoying this so much that we need to do so much more data processing, that we have. To run a few other services, out there and we, run them out on our application, on. Our existing VMs. Now. If this. Starts to sound overwhelming to you then you're not alone right and, we haven't even talked about, what. Happens if a machine dies so, if a machine dies here what. Happens to those services, do, we know that they died do, we how do we reschedule, them, so. This is where service fabric really, comes into play as a platform. In the. Service fabric world. We, take our VMs we install service fabric, on each, one of those and then. Service fabric is able to communicate, with amongst, the different machine, machines in our cluster and know. All the different, parameters. And. The. CPU. And memory and what what is available on those machines and, then. That. Comprises. Of our service fabric cluster. We. Then take our services. And talk directly to the service fabric api's and service, fabric determines, the best place to run the services. And in. The case of us machine failure. Servus fabric we'll look at the existing, machines in the cluster and then re, schedule. That workload out on to a machine, that works what works the best for. So. After service fabric at its core is an Orchestrator. But. It brings so much more to the to the. Plot to the table, it brings. Life management's, lifecycle. Management it brings health monitoring, even, brings programming, models on top of that and the best part about this is that any OS that it runs on any OS in any cloud and so. If you're running it on your dev box doing some dev tests that, same bits are gonna run up in Azure it's gonna run on that on your on-prem data. Center and then it's also gonna run on other clouds, so. I know what you're thinking we've been talking a lot about orchestrators. And. Big. And. Scheduling. Different services but I, have. An existing dotnet application, that's been around for many years it's. Stable, and that may be a fairly, loose term, loose, way to use that term and. It's. Critical, to my business, how, do I move. That application. On onto. The service fabric platform and take advantage of these things we just talked about. Well. First step is we're going to containerize our application, so we're gonna take our traditional, application, we're, gonna put. It into a reusable, format. We. Can package it up in a container in this case we're going to use Windows containers, or we, can take it and use. A guest executable, which, is just essentially a folder that has all your dependencies and you, give it to service fabric and it runs it across the platform the.
Next Step is to, modernize it by taking by adding new services, around, it supporting, services, that are going to enable you to become. More agile. Up. Next you can actually begin to decompose, that solution. That you have that. Existing, application, that your you're working, with and. Finally. You might get to the point where you feel like you have an entirely, transformed. Application. Now. It's really important to realize that these, are different phases and you can stop any of these phases and you'll gain a lot of benefits as you'll see today. And you, don't have to necessarily go, in this order in the, example, that we're going to go at the end you'll, actually see how, we jump over the modernize part and just go. To the decompose and extract out a service itself. So. What are the steps to traditional, eyes an actual application. You're. Going to take your application you're going to put it in a container this is where we use docker files docker, files is just a description of the. Different services that you want to run inside your, particular, container, you're. Gonna do a docker build which creates, the docker image you're. Going to push that to the azure container, registry and then. You're, going to tell service, fabric to pull down those. That. Particular, version of your, container. That you're running now you can think of container the azure container registry as a repository of, all the different versions of your application. Now. Any. Application, out there is going, always going to have some sort of data source. So. As your, sequel server, is. This data source we're looking at today and, it's a very common in some of the older applications. And, what. We can do is actually use address equal migration, service to migrate that up to address equal database, and. So this is a pretty good story of moving our application, to the service fabric platform. So, that's. Enough of the talk here we're actually going to dive in and see a demo of how we can containerize, it and move it to the service fabric platform and some of the examples that we have some. Of the examples of the the power that service rabbit brings to us. You. So. I'm going to switch over here to, our web. Forms application, I actually went out to the asp.net, website, and found one of the old sample, applications, from, I. Think. It was 2012, I pulled, that application, down it was built in Visual Studio 2012. I, upgraded. The application, and got it to run in Visual Studio 2017. And. Here. It's just a simple web forms application, there's. Actually quite a bit going on there's many different pages you'll, notice the aspx, and. This. Application, runs locally and what we're going to the first step we're going to do is we're going to add docker, container, support to it so, I can right click on the project, right, go down to add and add, docker support. This takes a, few seconds to just scaffold out a few things and you'll, notice immediately, that there's a docker file that is added to the solution, if. We look at the docker file it's using Microsoft's, asp.net. 4.7. It's. A image, that Microsoft gives us with is installed, and all the dotnet framework and everything. It. Sets, up a working directory in the eye net pub @ww. Root this is a place, where you, usually, upload your applications, in is, and then, finally it's just going to copy the, source, of this. Application, into. Our docker. Container. The. Other thing added was a docker compose project. It's, got a couple docker compose files. That Visual Studio is going to use to. Run. And build your application, now, this is all just using standard Dockers. Components. So you can take this docker compose file and run it yourself. I can. Press f5. Or play, and it's, going to boot the application, it's going to run through and build it and then deploy it. The point it, takes a half a second to connect the debugger the first time we're gonna take a look at what, happens in our docker container.
Are. With, our docker machine. Behind. The scenes so. Here, we can see that, it built out a wingtips dev, it. Wouldn't takes image with dev and, if. We, actually go and look at. The. Running services in the background will see that the, the, docker compose. Spun. Up a web service so we actually have a web. Server running in the background and the debugger has been connected to it so here's our web application, that we're going to be working with today it's, a simple ink karmis ecommerce. Website. And. Here. We have cars, we can maybe. Add a convertible car that sounds pretty good. Rockets, sound really cool to me so I'm gonna add a rocket, and I. Can, update the quantities, I'm, gonna buy two of these cars because they're pretty cheap and then, maybe route remove one of these rockets. Now this. Is running inside a windows container you can tell because windows. Containers gets a unique. IP for, each container that spins up on your local Windows 10 machine. And, it's, actually running through Visual Studio. So, I've already pushed that so, that it's ready to go I'm gonna snag this name here because we'll need it in a moment. So. We have our container. We've. Containerized, our existing application, I really, didn't change much inside, that application, other than the web connection string to. The sequel server database, and, then. We, pushed, it up to the azure container registry and. Now. We're going to add our service, fabric pot project. We. Can go to add, hope. I got to start the solution here. Ad. New project, service. Fabric application, will. Call it wing tip, toys. And I always like to put application. On the, end so I know that this project is essentially, the service fabric application. And. Then, we get to choose a solution. Template. That we want to use for building, out our application there's. A whole bunch of different options here we'll see another one a little bit later around. Stateful, services. But. Right now we're going to use the. Container. Template. And, a paste in the name of the azure, container. Registry and then, the name of the the web the actual, image that we're going to use wing. Tip, toys. Version. 1.0. Will, give name down here tip. Toys. Service. And. Hit okay Visual. Studio is going to scaffold out the service fabric application, for us and. Let's. Take a look at what actually scaffold, it out for us it's. Got a few different files up here I'm going to close these down so that we can look at them as we go.
Over Here, the first thing we'll see that, it created. Whoops, is. Our. Wingtip. Toys application, there's an application package route we're going to come back to that in a moment we'll take a look at what, it, actually means, to describe, your service fabric, application. But. In our application, parameters, there's a this. Is where we can do configuration, for our different environments. Under, our cloud here we, have instance, type of the. Instance counts of negative one this would actually deploy it across all our machines, for. Our demonstration, purposes, we're going to set it to one and then we'll scale it once it's running. Let's. Go back into our application, manifest our, application, manifest here we, can see that it has the the type that, we defined, before and then. The next interesting, part here is the service manifest, import the, service manifest, import is pointing, to another configuration file, that says this is the configuration. For the service, that we're going to work with so let's go take a look at that here. Up. Here this is the wingtips, toys service, and we'll notice down in the code package that we have an entry point and a container host this, container host is pointing. At that, hi. Docker image up in Azure container registry here. If we scroll down there's, endpoints defined this, is where we tell service fabric, what's the port that, we want to open up on the, local, machine on the host machine for. This particular, service we're, going to tell it to open up port 80 and, then. We're going to tell it to open up the protocol of HTTP. You. And, now. We have configured, our service and we're ready to go we have a couple more settings that we need to set up an application manifest, an. Application, manifest will. See underneath that service. Manifest. Import we need to tell service, fabric what is the container image, the, container host that we're gonna have, so. If I come down here I this. Is a little bit of code so I've just saved, it off to the side here. I'm. Gonna paste it in here and then we'll talk about it, so. This. Is our container host policies we're, saying, this is the port that the container is running on and then this is the endpoint reference, here wingtip toys service endpoint it's really important to make sure that this is the. Same that, is in our service endpoint, here and it, is. And, then. This. Is the repository correct, credentials to call back up to our Azure, container registry so that it pulls it down now, I've hard coded a password, in here but you can use. There. Are other ways to do this without hard coding and password in there. So. We are now ready to go with our application we. Can. Take. This and we'll, deploy. It out to service fabric I have. A service fabric cluster already out there by right click and go to publish. It's. Going to load a few of the, different, endpoints for our application. Now. Here. I'm doing this from visual studio but in reality in. Your production, environment you're, gonna have a build server that you're going to be working with here that you, can actually deploy. One. Source code check in it can, run and build this stuff so if you're using visual studio team services, there's already a template, out there for, service fabric and you, can just fill in a few parameters and it will take this information and, then go and build, it and deploy, it up to, the service fabric I'm. Gonna pick my service. Fabric cluster that I've already prepared. And hit. Publish, so. This will take a minute or two to build. The application, and. Let's, see here I've got a error, I think. I just need to build this before, I publish, it. Let's. Try that again. You. So, this is take a minute to build the application, and then publish it out to service fabric and that yeah that was the case there I didn't need to actually, build the application, again once I got the application, added.
To My solution. So. It's building, it let's go out to our service fabric cluster and this. Is our service fabric Explorer kind of gives us an information, around the different applications, that are running over. Here, we, can get information about different. Nodes, and then also the, system, the service fabric system applications, that are running out there that are managed doing all this management for us so. Now our application is running we. Can come in here and, click. On cars this, time I'm going to add a fast car and we, can see that this is actually running up in Azure in service, fabric we just took our web, forms application, added. Docker support, and then running it in Azure. So, one of the features that we can get now is we. Can take our application, type and in, that. Service we can scale it up so we, can scale it up to however, many we want here but we'll scale it up three so that we can see. What that looks like so, we've submitted that information, to service fabric service fabric is already, taken that information, found, some machines, that it can run this, service on and then, started. To boot them up and in just a moment it's. Already ready if we look up here on the right and all. The while I, can, still continue to use my application. So. What's interesting is, that service, fabric enables, you to be. Able to deep. To. Handle. Fault tolerance so if one of these machines goes down we. Can determine it'll, automatically, detect, that and then reschedule, that that. Existing. Service so, here this one's running on main - we, can come over to main -. And. We can deactivate this, machine so, this is just a warning that says hey. You shouldn't do this in production because this is going to take down one, of your scale set machines and you, could potentially lose data but for, our purposes we're going to spin. That down and in just a moment the machine will actually start being will be begin to shut down and we'll. See that that, service disappeared, and it's been rescheduled on, or. On. A different VM in our cluster, and again. All the while we can still come back in here and add. Other, carts, and continue. To work with our application. And, we can see it's already already, ready here, so. We're gonna dive back in that, was a quick example of how we actually move in our application, one thing to note is if we go back into Visual Studio all I, went through all these manual steps here a lot of this can be scripted and it can be put, onto your build server and with, the preview. Version of visual Studios servers, fabric add service, fabric tools you'll, be able to right-click on that, existing. Application, and. Next. To add, docker. Support will actually say add docker. Support, for. Service. Fabric and it will scaffold, all those things out so you don't have to do those extra steps that I saw. Okay, so, some, considerations, for when. You are moving an existing application. Session. State with, these with, web forms applications. Session state was commonly used and so you need to be aware that a session, State won't be shared as you scale out your application so take.
That Into account you, there's plenty of options to either, move. That off or, use. A different approach to how you you, store the state that you're working with, any. Memory, that you're using, in inside. Your application so if you're caching, any. Database. For calls that won't that cache won't be replicated, across your, instances, of your web service so you have, to probably use something like Redis, as an external cache system or, you could use one of the service fabric platform. Service. Fabric programming. Models which. We'll take a look in a few minutes. And finally now, you have multiple, instances all accessing, the same database be, aware that there, could be some conflicts, when when reading, and updating that data now that's these are things that you may have already taken care of inside your application, but, these, there's, things when, you're moving your application, you need to be aware of. So. Here we are we take our traditional, application, we've containerized, it and we've. Run it on service fabric we've already seen how we can scale, it fairly easily and then. We can, take. Care we can use the fault tolerance. Next step is now that we're running up in service fabric how do we get, insights, into our application, how it's running how, it is, performing, and behaving up in the cluster. Servus fabric is agnostic. To monitoring. Service. Fabric actually is. Agnostic. To monitoring and so you can there's a whole bunch of different ways that you can go about monitoring, but, there are three different levels. Of monitoring, that I like to think about the, first one is infrastructure, infrastructure. Is our nodes and our containers, it's our disk input-output. Memory. CPU, at a very kind, of granular level, the. Next level that I begin. To look at is the platform level so things that are happening inside, our service fabric cluster some of those is service. Fabric may determine that the, your. Clusters, needs, to be rebalanced, so that resources, can be used effectively and so, it puts, out events, for that if an. Application fails and dies, and moves to a different server, there's, also events for that and, then. Finally is your, application, and this is where you're looking for unique insights. Into your application, so it's very gonna be very specific, to events. That happen inside your your. Applique or particular. Service or the. Performance, of your, application, so how many milliseconds, or seconds it takes to process a request if, you see that spike up you might know that something's, kind, of behaving, improperly. You. So, again service. Fabric is. Agnostic, to the types of monitoring, that we do so. And there's advantages to all the different types one, option, that you have is OMS, this is great at the infrastructure, and platform, level it, also has a pre-configured, template, that's going to give you information for. Your. CPU. Memory, application. Service. Fabric platform events all of that stuff so it organizes. It in a very nice way for you. Application. Insights is another. Information. Happening. In the operational, channel we're getting our container logs so we can dive in to, each individual, container and look at a particular log, that's coming back out it's. Collecting our standard out and standard error. So this is very useful to just extract. That information fairly, quickly we're. Also getting reliable service events and we, get a count, of the applications, that we have out there and even, the images and here, you can see that there's, a whole bunch of images as I was doing debugging, and testing for this presentation I've collected some of that that information there, it's.
Also Giving me container metric and node metrics the, container metrics a little spotty because some, of the containers were spinning up and shutting down and then I wouldn't run them for. A few hours and then I would run them again and so you there's all different metrics. In here for that what's, coming up and node. Metrics. Now. If I come into my, settings for OMS, there's. A few items in here that I want to point out you'll, see that I have a couple different solutions. That I can easily add with, our pre-configured, dashboards, essentially, and then. Underneath connected, sources. You'll see that I have my Windows servers in the five computers, in my node, under. Data, I can, come in and add, windows. Performance counters I've already added a whole bunch of those but service fabric emits a ton, of performance. Counters around everything. That's happening inside the system and so you can come in here and configure, them and they'll show up in your logs here, this. Is a great way to get insight into your, service hybrid cluster and how it's performing. So. That's a really quick demo of OMS. But. We're gonna dive, back in and start talking about how we can take. Advantage, of the azure platform and its global scale. So, now, that we have taken. Our. Application, and push it up to Azure it's running in service fabric and since, service fabric is just a. Kid. An Orchestrator, it's takes, the VMS and it determines. Where they where. The services should run you can change the topology of your. Underlying. Infrastructure, and service fabric will just start to schedule. Machines, out there and one, of the things that we can take advantage of is the newly released availability. Zones in Azure available. Availability. Zones are physically. Separated locations. Within, an agile region each. Zone has its own independent, power network and cooling and so, if one of these zones goes down you'll, your. Service your application, if, it's configured, to run across all three would continue to run with, service fabric this is fairly simple to setup by, configuring. An arm template, now. There's three, zones and each a sure if. It's, available T, zone enabled, region and another. Thing to note is that inter. Availability. Zone communication.
The. Lit Network latency, can be up to two milliseconds. Within. A. Availability. Zone will be around, one millisecond, so there is that consideration, to take there but, I mean two milliseconds, is fairly small. Now. I'm not going to dive into the. Deep arm, template, today, there. Are some solutions, up on github for you to check take a look at that, but. What, we will do is look at a high level so. The, way that this gets set up is that you set up in a single V net and then. You in each one of the availability. Zones you, install, you you, run. Virtual. Machine. Scale sets with, a load balancer in front of them and then you use subnets, to connect them all three together and service, fabric there's one service fabric, cluster that is able to monitor all the machines, across that, system. So, if one of these, availability. Zones goes down service, fabric will recognize, that and start, to move the services, to, the other two availability. Zones now. There's a traffic manager, and that's actually optional and, available. Availability. Zones because, you can actually have a virtual IP, address, across all three availability. Zones, but. Many. Times you're if you're going to be going to this, AZ world. You're. Gonna probably end up going to cross. Regional. Clusters. As well and so having, the traffic manager out in front of there will prepare, you and get you ready for for, that scenario. So. Across, regional service fabric cluster is also. Something that you could set up so. You can set up set, it up to run across three different regions and this is really where you want to. Survive. An entire agile reason as your region going down and this. Is where you're looking at your RPO and RTO which are essentially how much data loss and how much time after, the disaster. Happens. That you have recovery. You want that to be zero and so if an azure data, agent goes down you don't have to necessarily spin, up services another location service, fabric is going to manage that for you recognize, it and everything, will still continue to run now. There's. A few minimum. Prior. Minimum. Things. That you need to have the first one is three. You. Have to have you. Have to use at least three regions, and then you have to have at least nine VMs, minimum and so this can get fairly pricey.
Fairly, Quickly so, just keep that in mind but, if you're really looking for that, high fault tolerance this is this is a solution that you need to move to. And, there's. 36 Azure regions across the globe so you can really begin to leverage the. Global. Scale of Asia and, it's. It's important to note here that you, don't have to actually. Take. Your server fabric application, and change it in any way you just are. Able to deploy it back out to the, server side of a cluster that's been configured, to run across the, availability, zones or the different regions. Now, we're going to dive into talking. About how do we actually modernize. Our application, and begin. To to, move to a microservices. Microservices. Design. Pattern. So. We've containerized, our application, where. We can now, begin, to add services, around the outside and supporting. Services in a microservices, manner. Or, we. Can begin to decompose it and we're going to jump right in to decompose just. To demonstrate that you don't necessarily need to move along, this path in a modular. Way you can kind, of jump around it's if you're very flexible, you. Do it best for the business that you're running. So, how do you decide where. You're going to actually begin, to add new, features the first one is if you have a new feature coming up and. It's, fairly. Independent. Logic wise and data source this is a great opportunity for you to to try, out adding. A new service a new, service in service fabric, another. Place is where. We use where, we can use monitoring, so again. We talked about monitoring a little bit from a global, more. Broad, perspective but. We can put monitoring, in our application, to determine hot, pass an existing, bottlenecks, where we're not able to scale and so, this, is a great place, where if we see a hot, path or bottleneck, in our application, and in our architecture we, can extract that out into a separate service. And it's. Important to realize that we should always start with small features now, that your applications running up in service fabric on the, Azure platform I'm. Sort of latency and so, we need to be aware of that now, the. Benefits, that we get from, increased. Mobility. And, agility, and, the. Independent, deploy ability and scale usually. Outweigh, that latency, hop but it is something to consider. Now. Another. Thing is now, that we have that network hop there. Could be failures, and so we need to have some sort of failure and retry, p--, strategy. So, if the service goes down do we continually, retry, until it comes back up do, we back off exponentially, what. Happens if there's. A cascading, set of failures we, need to come up with some sort of strategy for all these different scenarios and it's going to be different from strip from one service to another. Now there's, also existing, patterns out there such. As the. Circuit. Breaker pattern and that, circuit breaker pattern, will enable you to handle. Some of these failures cascading. Failures and such.
Now. We, touch upon shared, state previously, but, when. We start to break out services we're gonna have to have some, information shared. Between between our different data sources and so, we need to be aware of that shared state and how it's being shared and, determine. Whether or not some of that data can be stale how, long it can be stale there's a whole bunch of different things that we need to think about here and so these are just a few different ideas, to, keep in mind as you begin to move migration, in your migration to a service fabric and, micro-services. Solution. So, service fabric brings us, these stateful, programming, models on top, of just being an Orchestrator, the, first one the, first one that it brings is this stateful where the high level services this essentially, enables, you to work with your state, through. A key value pair, dictionary, with with transactions. Support, built-in, so. An existing, application generally. You have some sort of stateless, front-end, that's kind of your. JQuery. And angular. And all those other applications, out there and. That's, calling, out to, a middle, tier where there's compute and then that calls out to a database and the, service fabric world you call out to a, stateful, middle, tier so we've taken the data and brought. It up next, to the compute and this, enables, lower latency, less. Management. With, how that. That. Call those calls need to be made out to the database. So. This. Is an incredibly powerful technique. And it also enables, us to start, to begin to think about how we actually partition, our, solution. And. Run. And. Run. Our solution in a distributed. Manner. On top, of that there's. Also the actor model an, actor model is a great programming, model for when. When. Your, particular. Solution. Really, fit them in the way that you scale but. You got to make sure that it's fitting, into the actor model really well. So. We, are going to go into that existing, web forms application, that we have, already seen and then. We are going to. Extract. Out the shopping cart so we're, going to go in and extract out existing, solutions, the, reason we chose the shopping cart in this scenario is, because it's a small feature it's, a fairly.
Existing. Module within the solution but it's also incredibly important, to scale. And. Important, to the business this is where all the revenue really comes through. It, also opens up new interactions, if we extract this out into a service we're able to scale it and enable. Our mobile, applications, and our email marketing campaigns. To interact. With our shopping cart to extract. New information, and. Hopefully. Serve our customers better. And then, what. Latency is incredibly, important, in this scenario I mentioned. That the revenue this, is the key, source of revenue for the organization. And so we want that shopping cart to load quickly we don't want them to have to wait because they might go to another store and so, using. The reliable, services we'll get that low latency kind, of out of the box using the, stateful. Middle tier. We're. Going to dive in and take a look at one of it one of these demos looks like. You. So, in, the. I've. Already kind of already, pushed. The code out and. We're, going to take a look at all that code there. Was quite a bit of code that had to be written to to, extract, it a construct, out the service so we. Were going to be able to do that live so. The first thing you'll notice is that I have a new applicant. A new project here called our shopping cart and if. We go into our wingtips. Toys application, and, we look at our application manifest, we'll, see that I now have a. Service. Manifest, and I'm bringing in this shopping cop package the, first thing we're going to do is kick this off and upgrade, the existing solution, that we have out there and then I'll walk you through some of the code that we've we've, changed so. I can right click on my wingtips. Application. Click. Publish and, this took this time I'm going to check this tip. I'm. Going to check this check box for upgrade. The application, I'm. Going to push it out to the same solution and then. Click publish. And this. Is going to build the application, and then, initiate. An upgrade and so now we'll be able to see the rolling upgrade happen, in time I'm kicking, this off while we go back and look at the code because, it can take a few moments to complete the.
Entire Upgrade, across our five different upgrade domains. So. Here it is building the application. Should, kick off the. Upgrade. Sure it's successful and then we'll go take a look at what it looks like inside, our. Our. Service fabric Explorer here in a moment. Okay. You. Let's, see. The. But they upgrade, in progress but. We can take a look at our cluster map map so, we have our machines. Running across multiple, fault, domains and multiple. Upgrade, domains so, that means we're gonna be able to do this rolling upgrade across. Our, service. While, it stays up so, it'll take down the first machine but. The other machines will stay up as it's upgrading the service. In, tip toys service, package. Number. Is the, same. But. I upgraded, that let's check one more time we'll try one more time here. Get the code. I'm, going to kick that off well, that's kicking off hopefully we'll be successful this time and, we'll. Go look at the code that we've. We've modified so, inside our shopping cart actually. So here we've, added. A, s. Service, I've already added it but the way we would add this is right click add new, service fabric solution, service. And would Temple, it out and give us those options, that we saw previously and, add. It to our application, manifest and then. In here in, our shopping cart this. Is an asp.net, core. Reliable. Stateful. Service and if, we go to our program, this is where we would typically see our asp.net, core. Startup. Information, here instead. We're seeing where we're actually registering, it with service. Fabric we're, registering the shopping cart class if, we go take a look at what that shopping cart class, looks like we'll, see that shopping cart, inherits. From stateful, service and. Below. We'll see that, we, have create, service replicas listeners, and this, is where we're actually configuring. Our service. Fabric, sorry, our asp.net, core, application, so. Here you, can even see that we are, configuring. Up our. Dependency. Injection, for, asp.net, core, if we. Go out to and we're, also setting our you, start, up. Class, we, go to startup class this is just going to be asp.net, core, so we have our startup we have our configuration services. And we have our configure, you. Can see I've added swagger. In here and a few other things and. If. We go up to our cart controller we'll, see again this is just an asp.net, core, controller. But. On our. Constructor. We've actually injected, in the, reliable. State manager. That. State manager. Is where we're actually going to interact, with this, the different replicas, that we have for managing, our state. I've mentioned that we have that the state is just a reliable dictionary so in this line here we're just telling the state manager hey go, get the dictionary. For us and this. Dictionary is going to have a key of string and a, value of cart, we. Create a transaction anytime we're working with these reliable dictionaries. We were always going to work with transactions. This way if something fails during one of those transactions, it'll automatically, get rolled back for us. We're. Gonna try, and get the value out of the dictionary and, put it in a result if the, result has a value we'll return the items if, not it's, going to just, return an empty list. So. This is deceptively, simple, for what is actually happening, on in, the background in. The background your, data is being replicated. Reliably. Across, many nodes and if. One. Of these nose goes down then, your data will still be around and it will automatically, figure. Out how to. To leader elections so that your service, pops up and stays. Alive for you but. You can see how simple the programming model is when, you're working with it let's. Look at a little bit more complicated one. That. Uses some transactions, so, down here this. Is our. Power. Wingtips. Application, sorry, web forms application, and in. Here if we go into our logic, we'll see that it, was already separated out into the shopping cart actions, the, shopping cart actions, was. Kind, of where all the business logic relied. To access, the data. I've. Extracted, out, it. Was using entity framework to pull that information out of the database and. Instead. Of calling, to enter framework what I've done here is call. Out to a web service I'm using, refit. To make, it fairly simple to call, out to those web services and I. Create. Return of client and then I call add item if, I go and look at this interface here refit. Enables, me to just define my, web. My. Web client through, this interface I can specify, the, endpoints. That we're working with in. In. These. Attributes, and you'll, notice that they kind of match to all the different ones that we had in our asp.net.
Core, Reliable, service. If, I go back to shopping carts when, I actually call, to, add an item to it you'll notice I'm also passing, off a partition, key I mentioned, that these reliable services are partition, aware now, in, this solution, I am exposing. The client, to the, partition, key here because I wanted to kind of show that here but we can also hide, this partition, information, in another service, so we can have a kind of a stateless solution. In the middle where if you call out to it and, you supply the shopping cart ID it will automatically, figure, out how, to connect. To your. Your, exact. The right partition, in your application. We. Scroll down to a little bit further. Down. To let's. Get the cart. Items now, this. Existing application. Was. Working with the, database. And so the products information and the card information was. All in the same database we've extracted, that out and put it into a separate, data store the reliable, collections and so. When, we get that information back from our, web, service we need to merge it with the product information and so I've written a little class that takes that and calls, down to sequel server and then merges, those back together and returns it back to the client to display it so there's, a little bit of merging, of data that you need to do here it's, not too bad if we take a look at that, functionality. Here. I'm just joining I'm using link to just join a couple of the things together on it on the product IDs after, I call out to the database. You. So you also know that notice that I'm using async/await. So that required a little bit of change, to, my. Solution so if I go into my, web, forms application. See here. Thank art by, going to my web forms application, on the page load I needed, to. Enable. Async, support in web, forms and so. In web forms you go into your, asp.net, aspx. Page and you, enable, async. True and then, inside, your page, load you use register, async task, now I wanted to modernize my application, I didn't want to just continue doing, the same things I've been doing in the past and so that's why I introduced, this async await required, quite a few changes across, my. Solution, but ultimately. I think it makes a better solution here I've even upgraded, and, started using the latest version of c-sharp so C 7.1. That. Required just a small change to bring in some libraries, some, new get packages, to enable, the compiler, when the thing boots up. So. With. Any luck we. Should see that our application has, gone out and, did. A rolling upgrade so. If we come out to. You. Yeah. Well. It didn't get the rolling upgrade. Because. I think, I got some naming things wrong but, it did go out and deploy a new service, let's. See is this. This. But it does what that. New functionality, using service fabric reliable, collections, and. Extracted. Of component, of our application, and turn, it into a micro services. Started. Our journey towards, micro services. So the, source. Code for. The solution, with all the commits, to make all the different changes is out. On my github here github. Calm, /j. Sturdevant service fabric modernized connect, 2017. So. You can go take, a look at that you can download it you can build it there's some some. Scripts, to set, up the infrastructure, and get, get yourself set up. Next. There's, a lot, of information out there for you to learn more about service fabric so you can go over to Microsoft, Doc's. Top Microsoft, comm and check. Out the service fabric documentation. There are ton of free, open-source. Samples. Out there there's even free clusters, for you to try and then. There's an incredibly. Comprehensive. Resource, list that's been putting together by one of the community members there's also documentation. On more, information. Around how you actually migrate, to the cloud and then if you have any questions, comments. Concerns go. Out to the service fabric forum and the. Service fabric issues and. Raise. An issue and ask us questions where the, team is out there and they're happy to answer questions. So. With that my. Name is James. Sturdivant, I'm a senior. Development, engineer on our. On. Our commercial, software engineering team and I'm so, excited to share, this information with you and two. For. You to take. It and run, with it and I wish, you luck on your journey, to a sure and micro. Services.