Okay, now we're all set up on Azure to deploy our application.
So let's head back to VS code.
And I'll just close all of this stuff down and let's open up our terminal.
We'll stop our API server from running.
And inside here we're going to create a published version of our.
Net application.
In fact, before we do let's go to Source Control and we'll stage and commit our changes prior to publishing.
So I'll stage the changes and I'll just say pre publish as the commit name and I'll commit and I'll
sync them up with GitHub.
And then inside our terminal inside the API folder we will use dotnet publish.
And then we give it a configuration value.
And we'll give it a value of release.
And then we'll give it an output directory.
And we'll say period forward slash bin forward slash publish as the directory.
We're going to publish our compiled and built production enabled application two and press return.
And this will go ahead and do just that.
And if we go and take a look at our File Explorer this time because we don't see our bin folder inside
Solution Explorer.
But if we go to the File explorer expand API expand bin, then we've got our publish folder.
And this contains effectively our application.
It's got our root folder copied into this as is.
And then we've got all of the DLLs that make up our application.
All of the parts of DotNet that we've used inside our application that we're using, they're all get
built into our published version of our application.
The idea being that we can take this and run this on any server that has the.
Net runtime available.
And of course Azure does have that available.
So how do we get this from here to Azure.
Well we'll use a VSCode extension to help us do that.
And if we do take a look for Azure inside here, then what we can utilize is the Azure App Service Management
extension for Visual Studio Code.
And this will give us an option to right click and publish to Azure.
So let's go ahead and install this one.
And once this is installed let's go back to our File Explorer.
And in fact what we do have now is the Azure extension available.
And it looks like it's picked up from a previous sign in for myself.
So I can see Azure subscription inside here.
But if you do come on to the Azure tab, then there should be an option to log in to Azure through this.
And once you've logged in you should see something similar to what I have here.
But we're not going to use this tool like it is to deploy our application.
We'll go back to the File Explorer and we'll go to our publish folder.
We'll right click and we've got a Deploy to Web app option.
I'm going to select this one.
And this is going to go out to Azure and check what's available for me to deploy this to.
And the one that I'm going to deploy it to is Restore Course, the one that I created in the demo previously
or in the previous lesson, and select that one.
And then we'll get the pop up saying, are we sure this will overwrite any previous deployments and
cannot be undone?
I'm going to say, okay, deploy and then we'll get another prompt.
Always deploy the workspace here.
I'll say skip for now, and then we'll get our progress inside here.
And already that has happened and it's been deployed.
So then we can browse the website.
So if we go across to our browser I may need to do this in a new browser window because I don't think
refreshing is going to do it.
Oh, it has done it in previous testing that didn't have the desired effect, but we do have now our
Are deployed application living on the internet.
And if I go to the catalog, then we can see our list of products and all of our functionality should
be working as it did before.
It's very fast.
This is deployed.
This is on the internet.
This is not local.
This is a SQL server and our web app living on the internet.
And if I add something to the cart then we can see that functionality is working again.
It's lightning fast in fact.
And let's click on our basket.
We see the products that have been added there.
We'll test a bit more functionality, and the loading bar doesn't barely get a chance to appear before
it's already loaded.
So pretty fast.
And I'll click on checkout, which takes us to the login.
So I'll log in as Bob at test.com.
When we deployed our app and Azure started our app, it would have seeded the data in there.
So we should be able to use our Bob at Test.com user to do this.
So I'll sign in and then we get taken to our checkout page.
So I'll just pick an address in the US, and I'll use Bob test as the name and in the address.
We should still have our Google autocomplete here, so we can start typing the first line of the address.
And then we get some options.
So let's go for this one here.
Doesn't really matter of course.
And I'll click on save as default address.
And I'll click on next.
And then we get taken to our card number.
So let's try a successful payment because we should see the full process here.
Because stripe is going to be sending that webhook to our deployed application.
So I'll just add the standard card number of all 40 twos.
I'll put an expiry date in the future with the security code.
I'll click on next.
And then we get taken to our billing and delivery information, etc. and then I can pay seven six,
eight and I'll try this and we get the success.
And if we go and view the order then we can see that the payment has indeed been received.
And that confirms that stripe has sent the webhook to our API endpoint on our production server.
So awesome.
We've made it.
We've got our published application on the internet.
We're able to make an order and successfully receive the payment, so that was pretty easy.
But I do want to take the deployment a step further, because we had to right click something and do
something manually to deploy our application.
Wouldn't it be nice is if we made a code change and added some enhancement?
Or a new feature to our application is if when we deployed that updated code to GitHub, then something
automatically happened in the background to then publish those code changes to Azure and automatically
updates our published application.
And that's effectively CI, CD, which stands for Continuous integration, Continuous Deployment or
often shortened to just Continuous Delivery.
And we're going to take a look at that and implement that next.