This workshop will be retired on May 1, 2025.
Heads up! To view this whole video, sign in with your Courses Plus account or enroll in your free 7-day trial. Sign In Enroll
Preview
Start a free Courses trial
to watch this video
In this video, we'll learn how to use Visual Studio to publish an ASP.NET Core application to an Azure App Service.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
So I wanna do a couple of things.
0:00
I'm gonna jump back and forth between
the command line and Visual Studio.
0:01
But I wanna make sure that people who
don't have Visual Studio understand that
0:03
everything I'm doing can be done
whether you're on a Mac or a Ubuntu or
0:07
whatever makes you happy.
0:11
So for example, here I am at the Command
Prompt and I typed dotnet new mvc.
0:12
I could type dotnet new angular or
dotnet new this and that.
0:18
And I went and created a web application,
so here's my web app.
0:21
This is a model view controllers
style ASP.NET Core application.
0:26
And this is the same web app that
I would get if I were to come into
0:30
Visual Studio and say, File > New >
Project, pick .NET Core and hit OK.
0:35
So here I am in another web
app that is in Visual Studio.
0:41
And I get that same experience, all right?
0:45
I just wanna point out,
I've got my Controllers and my Views.
0:49
I come out to the command line,
same kinda thing.
0:52
So two different deploys
in two different ways.
0:54
There's in fact many different ways
to deploy your application, but
0:58
these are the two most popular ones.
1:01
From within Visual Studio, I can
right-click and I can say, Publish, okay?
1:03
When I say Publish, it pops up this
dialog box with a couple of options.
1:09
And it's important to point out this
arrow here that says I can scroll further
1:13
to the right.
1:18
If I click on that,
I can go all the way to the right.
1:19
And you'll notice that we
actually hid something there.
1:21
We hid Microsoft Azure Virtual Machines.
1:23
It's not that we hid it because
we don't ever want you to use it.
1:26
But it's just not the most
popular way to do things.
1:29
If you remember that first
slide at the beginning,
1:31
this is the lowest level way to do things.
1:34
Now, if you click on that, we'll make
you a virtual machine, we'll set up
1:36
a web server, and we will set up
publishing, so that you can be successful.
1:40
So the result will be
a website in the cloud,
1:44
except it's on a virtual machine
that you are now in charge of.
1:47
It's free and wonderful,
but it's free like a puppy.
1:51
You have to feed it and
you have to deal with it.
1:53
So be aware that it's there, but
1:55
probably not the easiest thing
to do if you're a web developer.
1:58
I could also publish,
of course, to a folder.
2:02
I could publish to a local web server or
2:05
even use FTP if I do insist on
using cheap or commodity hosting.
2:08
What I'm gonna do is I'm gonna
click Microsoft Azure App Service.
2:12
I can select an existing App Service if
I've already made one in the Azure portal.
2:17
But I'm just gonna sit here in
Visual Studio and say Create New and
2:21
then hit Publish.
2:25
Now up here it's saying
enter your credentials.
2:26
I'll actually reenter my credentials,
mine have expired.
2:28
And when I log in, I'm just using
my same login that I use for Azure.
2:34
So as we log in, it's going off and
getting my subscriptions and
2:49
my information from Azure.
2:53
You see here, now it's gonna find out
what active subscriptions I have.
2:55
I can use my 3-month free trial, and
2:59
you could certainly do that as
well if you signed up for one.
3:00
But I also have an MSDN or a Microsoft
Developer subscription account,
3:03
so I'm gonna use that.
3:08
And then I can create what's
called a resource group,
3:10
or I can pick an existing one.
3:12
A resource group is really just,
3:14
imagine I draw a dotted line
around a bunch of websites.
3:16
If I have one website, well then,
I just have a box around one of them.
3:20
But if I was gonna make the great new
American startup, I might have five or
3:23
ten websites.
3:27
I'm gonna draw a line around them and
I'll name them.
3:28
And I'll be able to refer to
them as a group of resources.
3:30
Then an App Service plan,
now this is a little confusing,
3:34
because you've got some codes
here that don't quite make sense.
3:36
You've got F1 and S1.
3:39
F is for free, so that is a free.
3:42
And there's 1, 2, 3, 4, this is number 1,
this is the basic free account..
3:44
I have a standard account, and
I can go and make one from here as well.
3:49
If you go here, you can see the codes.
3:53
S1 is a standard virtual machine
with 1 core and about 2 GB of RAM.
3:56
And then P is for performance,
and those are bigger, stronger,
4:02
faster and of course, more expensive.
4:05
Now B is for basic.
4:08
The difference between standard and
basic is load balancing and backup and
4:10
some of the more advanced features.
4:13
Free is a little slow for my taste.
4:16
I would recommend people try Shared or B1.
4:18
Here we are now,
we're talking about virtual machines,
4:22
that can be a little confusing.
4:24
Didn't he tell us we weren't
gonna talk about those?
4:26
This is where, it'll save you money,
and it'll make you a better developer,
4:28
if you understand that there is
a virtual machine underneath.
4:32
How do you best utilize that?
4:35
So for example,
I'm gonna pick DefaultServerFarm, S1,
4:37
a standard virtual machine, and we are
reminded that it has almost 2 GB of RAM.
4:41
I don't need 2 GB of RAM for my website.
4:47
I don't, it's overkill.
4:51
But that doesn't mean one
App Service plan equals one web app.
4:53
In fact, I can have hundreds.
4:57
I can have as many web apps in my
App Service plan as I have the memory to
4:59
do it.
5:04
Now, if I were doing free,
that doesn't make any sense.
5:05
It's really one to one.
5:08
Shared means I'm on a computer or
a virtual machine with somebody else.
5:10
But even with a basic, you can have
dozens and dozens of websites.
5:14
So in your experience, as you move through
all of the great Treehouse tutorials,
5:17
make a Basic 1,
make a Basic 2, and use those.
5:22
And then, put all of your samples and all
of the things that you're gonna build as
5:25
you go through this experience with us,
in the same App Service plan.
5:30
So I'm using the same resource group and
the same App Service plan.
5:33
And I can name my web application
whatever makes me happy.
5:37
So now I'm gonna hit Create,
Now if I had clicked Services,
5:41
that's where I could sign up for
things like a SQL Server and a database.
5:46
And that would be something that would
be the back end for my application.
5:49
I also could have clicked change type and
selected a mobile app or an API app.
5:53
And there's all kinds of great stuff
you can make with Azure App Service.
5:58
But in this case,
we're just gonna make a web application.
6:01
So now it's setting up your profile.
6:05
And your profile is all of the stuff
that you need in order to publish.
6:07
And you can import and export profiles.
6:11
You can give profiles to someone.
6:13
You'll notice earlier, when we clicked
Publish, there was an option for
6:15
import profile.
6:19
That's a way for you to securely and
safely pass around your passwords, and
6:20
the ability to publish to your web
application without giving people your
6:24
Microsoft login.
6:28
Now you notice here that we did a build,
and now it's doing a publish.
6:30
It's adding directories.
6:34
It's sending information
up to Azure right now.
6:36
[SOUND] And now, I didn't do that,
it automatically launched the browser.
6:39
And notice that it put it at my funky URL.
6:44
Now the funky URL doesn't really matter,
that's an automatically generated URL.
6:47
I'm gonna probably register a domain and
then point it at that funky URL.
6:51
So I'll never really see that again.
6:55
So don't get too hung up on that.
6:57
And there you go,
6:59
I've got an ASP.NET Core application
running in the cloud at this funky URL.
7:01
And then I could go and set up my DNS,
my domain name services and point my
7:07
super sample application.teamtreehouse.com
to my application and we'll be all set.
7:12
However, I did use Visual Studio.
7:19
Some of you may not be
using Visual Studio,
7:22
so we're gonna show you how to
do that from the command line.
7:24
But I just wanna remind you, again,
you can have different profiles.
7:26
And one of the other things to be thinking
about is you could have dev and test and
7:29
staging.
7:34
You could have multiple Azure websites for
one application.
7:35
So here I've got funky URL, but
I could have dev, test, staging.
7:39
Create another published target, then
I might wanna publish this to staging,
7:43
test it out, have my friends look at it,
and then switch it over to production.
7:47
I can do that really easily.
7:51
Or I can import a profile that
someone else gave me, like this.
7:52
That hides all of your passwords and
all the information that you need.
7:56
And I also want to point
out configuration.
8:00
I'm doing my work here in debug mode.
8:03
You might want to send debug up for
staging and then release into production,
8:05
totally up to you.
8:10
But you also get all
these information here.
8:12
Wanna point this out,
if I say View Details,
8:14
I click Web Publish Activity
go to View Details.
8:16
If anything went wrong,
8:20
I could see that here in the logs
as it sends those files up.
8:21
And of course, nothing did go wrong.
8:25
We had a successful publish.
8:27
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up