From the course: Introducing ASP.NET Core

Publishing a website to Azure - ASP.NET Tutorial

From the course: Introducing ASP.NET Core

Publishing a website to Azure

- We did it. We have reached the end of our ASP.NET Core 101 video series, but we haven't told anyone. We haven't published it to the cloud. - [Leslie] Right, we need to let the people know. - That our craft site is better than all the other competing craft sites. - Absolutely. - All right, so let's try to go and publish this to Azure. So I'm just going to switch back over into... Actually, I'll show you our site real quick. It's lovely. Just want to show you how nice it is. - [Leslie] Six star rating system. - That is the differentiator for our- - I agree. That's what makes us truly special. - Six star. All right, let's do this. What we're going to do is right click on our product. Remember when we talked about this before. You can build, you can clean, you can publish. So when this pops up, there's lots of different places that you could potentially publish your vision to. If you want, you can just publish it to a folder and then zip it up, and take it over to your friendly neighborhood host. If you have your own server, maybe you use IIS, the Internet Information Server for Windows. Maybe an Azure virtual machine, but what we're going to do is, we're going to publish it to an Azure App Service. Azure App Service. Here's one for Windows and here's one on Linux, and we can just say create new, and because I'm logged in to Azure, it's going to load my subscription, see? - [Leslie] Nice. - [Scott] So Contoso Crafts is awesome. - [Scott] So Contoso Crafts is awesome. We'll figure out our domain stuff later. We need to go and get VC money. - [Leslie] Yeah. - [Scott] Okay, I can pick my three month trial. We can make a resource group. I'll just leave these things as they are, and then here under web hosting plan, I can decide whether or not I want a machine of a certain size. I could even try this on a free if I wanted to. - [Leslie] That's nice that it's letting you do all of that in this model. - [Scott] I could log into Azure and the Azure portal, and do all that stuff, but I can do it all from Visual Studio, which is really cool, and then if I wanted to add a database or a storage account, totally up to me, and then additionally, I can export those settings, and then I could give them to you, and you could publish from your machine as well. Let's go and hit create. We'll see if this works out. So I'm hitting create, and it's going to go and deploy. It's multiple steps, so I'm just going to be patient. It's going to create what's called a hosting plan. This is the thing that is going to hold our website, and the cool thing about using Azure App Service, is I can do deployment slots. Have you seen those? - No, I haven't. - Dev test, staging, all on the same plan. So you can go and deploy to staging, and then I can swap staging with production. - Ah, so convenient. - It is convenient and we'll be able to do it on all of the exact same plans, but right now, we're just going to publish directly to production, because that's how we roll. - [Leslie] Yep. Get it right the first time. - Mm-hm. This might take a few minutes depending on the status of your system. on the status of your system. In my case, I am using my trial account and I've never made a hosting plan before. So I'm going to wait for just a few minutes here. So we might compress time in the interest of not boring people. - So maybe while we're doing that, what do we do now? We were about to ship and oh-- - Oh, hey, look at that. - That was faster than I expected it. - All right, so this is great. So while you were getting ready to stretch out the amount of time we were talking about, in fact, they created that and we can publish directly from here, and we can also be reminded that we can pick our target frameworks. We can use .NET Core. We can decide whether or not it's going to be going to Windows or not. Whether or not it's going to be entirely self-contained or not, and it's warning me if I set the wrong setting. Here, I'm going to go into a self-contained release build, directly out to Azure, and then you see our initial URL, contosocraftsisawesome, and then here it says-- Hey, there's some warnings. You don't want to let me know about your warnings? They're saying that we're using a thing called SignalR, and then SignalR runs blazer. If we were going to go to production production, like scale and take over the world, which is ultimately our plan. We could also use the Azure SignalR service. Let's go ahead and hit-- - [Leslie] And we can edit all of this stuff at any time. - [Scott] We absolutely can, and we can also go log into the Azure portal and see those settings, and download and export a profile and then import that individual studio. So you can do it from VS if it makes you happy. You can do it from the command line or from the portal. All right, so we're publishing there, and you were going to suggest that we learn about some resources. - Yeah, because now that you've completed all of this, congratulations. Hopefully, you've learned a lot about ASP.NET and now you're just wanting to learn more, so - So let's do this. We can go up to the Contoso Crafts GitHub. That's a github.com/dotnet-presentations. We are inside of ContosoCrafts. This is going to be a living and working sample. So you can get involved. You can improve it. You can fork it, play with it. It's all open source. Be sure to check out the .NET website. Up at the top, there's two things I want you to look at. There's learn and there's community. Videos like this will be up at learn. You can make websites, and IoT devices, and android things, and iPhone things, and all kinds of stuff. There'll be videos and learning materials up there, but also to your point, the community. - [Leslie] My favorite. - Yes, meetups, GitHub, Twitter, the community standup, where we meet on every week. We've even got a Gitter and a Discord now, which is really, really cool. All right, let's go back to Visual Studio and see how our publish is going, and it worked. It's up: contosocraftsisawesome.azurewebsites.net. We did it and you can do it too. You can right click in Visual Studio. You hit publish. In this case, we made a new Azure App Service and deployed, and it worked and I'm pretty happy with myself right now. - Yeah, that was pretty good. I'm feeling pretty good. - Yeah, so how can we learn more about this stuff? - Well, I like to talk with other people first and foremost. So we can go into the .NET communities. So that can be at a Stack Overflow, or Discord, or a blog. Anywhere, we're all over the place. - Mm-hm, and you can go up to the .NET website and click/learn where you can see these videos and lots of other videos, and reminder: this is not the only video in the series, and it's not the only other series. There's C#, there's .NET, there's mobile, and lots, lots more. We look forward to seeing you online making more .NET code. - Happy coding.

Contents