There are a couple of ways that you can go ahead and create a new cloud service.
Earlier in this course, we created a cloud service called up and running.
You'll notice we have a production
environment running, but no stage environment.
If I click around, hit Dashboard, you'll see
that basically we have nothing going on here.
Just one single core for our production environment.
If we go down to the Command
bar, and you hit New, we can also create
a cloud service by coming in to Quick Create.
We'll call this univtest.
We're going to create it in the West US region.
You'll see it's immediately created.
If I click on it, I can move over
to instances, so production, and staging both have nothing deployed.
I have no linked resources, no certs, and I can configure and monitor.
But it's basically at this point a blank
service I'm going to go ahead and delete this
service, say, Yes, and we're going to go
ahead and create a service directly from Visual Studio.
So let's go ahead and switch to Visual Studio Express
for Web and we're going to create a new project.
Now, since we have the SDK installed, you'll notice I
can go to Visual C Sharp and click cloud and
say Windows as your cloud service.
But what I'm going to do instead is start by using a web application.
Inside of a cloud service, a web application is
going to fall into a category called a web role.
So I'm going to click on an MVC 4 web application.
We're going to call this Univ for university and
we're going to click OK and take the defaults.
Let's go in and edit our standard view, so I'm going to come to Home, Edit
the C Sharp HTML here, and we're going to get rid of all this boiler plate code.
And we'll just say, Welcome to Azure Up and Running.
I'm going to go ahead and Save, and we're going to run this application.
You'll notice now that we have a Welcome to
Azure Up and Running, with our standard MVC4 template.
Let's go ahead and close this. Let's open up our home controller.
I'm going to comment out that message, just to clean everything up.
And you'll see, we're also using IIS Express, running on local host.
So we're in our home page, and I have a Welcome to Azure Up and Running.
Now, if I want to move this from a sample web
application into a web role, I'm going to right click.
And I'm going to say, Add Windows Azure Cloud Service Project.
If we scroll down, you'll see I have a new section.
There's a little picture of a fluffy cloud and it's called Univ.Azure
and I have one roll. This roll, if I double-click, happens to
be the ASP MVC4 site that I've created and I have currently one small VM size.
So I can move in here and change
to all the different VM sizes, you'll notice these
VM sizes match exactly to what we've already covered
in the virtual machine sizes, earlier in this course.
I can also set the settings here.
So for all configurations, I have cloud settings, and I have local settings.
These files match exactly to the cloud.cloudservice config
files that you see here.
So if I double click on cloud or local, you'll
see I have Microsoft Windows as your plugins diagnostics connection string.
And this is saying to use development storage for everything.
So earlier in this course, you remember,
we set up the Azure local environment, this
allows us to run an entire cloud
service locally with an emulated compute environment and
storage environment.
The way that we test this out locally is to right click.
Set the cloud service project as the start project, and then run this.
When I run this, you'll notice it's going to ask
(SOUND)
for admin privileges.
We need to run the Azure compute emulator as elevated.
So we're going to go ahead, save our project.
We're going to close this.
Go back to our Start menu.
We're going to click on VS Express for
Web and we're going to say run as administration.
You'll know you're running as an administrator when you
see administrator in parenthesis at the top of visual studio.
Let's go ahead and run the university app.
We're going to make sure this is our start project.
And run.
And now you'll notice, we're going to
deploy this to our local compute environment.
If I go down to the bottom, and I say,
Show Compute Emulator UI, you'll see we have the same
page that we had inside our standard MVC4 application, but
it's now running on local host, and it's running inside
of our compute environment.
If I look over here, you'll see I have
a single service, and it has a univ web roll.
I double click on that to show you the text, and
you'll see this is basically the cloud running on my local PC.
So I have full access to all of the APIs I
would in the cloud, but I haven't actually deployed anything yet.
So this will give us a great way to go ahead and test, and
make sure everything is working before we deploy all of that to the cloud.
I can also go to the bottom and show my storage emulator.
So, you'll see now blob queue, and table storage
are all running locally, and all part of this service.
Don't worry too much about that right now.
We'll cover that in the next section when we go over data services.
For now, let's go back and start adding some functionality to our new web roll.
We're going to go over into the Home Controller, and
we're going to add a new method here called Newsletter.
So the idea here is that we're going to have a cloud service that
will accept email addresses from people who
want to sign up for our university newsletter.
So let's go ahead and add a new method, we'll
call this Newsletter and it'll take a single argument called email.
Now, we want the
ability to go ahead and do an HTTP post
back into this controller, so we're going to say HTTP
post, it's the type, and we're going to add email
to the view bag, and then return the view.
We also need to go ahead.
And change the index method to say newsletter signups.
So, let's go ahead and get rid of
this commented section, and I'll say newsletter signups.
And if we go ahead and run this, you'll see
it's going to deploy everything back into the compute environment.
It'll take a second for it to spin up.
And now we have our newsletter sign ups. Let's go ahead and add a form.
So we're going to open up the index.csharp html again.
And here at the bottom, I'm going to add a new form.
So we'll say, form, action, equals. And we're going to create
a new newsletter in a second here so that's where we're going to
want to post And let's do some HTML so we'll say HTML textbox.
We'll have one for email.
And our input type will equal submit, and our value will say sign up.
And we'll save this. Now let's go ahead and add a new view.
So we'll come down here to Views, poem /g, we'll say, Add a View I'm
going to call this view, Newsletter. We'll say, Add, and we're going to say,
New Article, thank you for signing up for the newsletter.
We will use, an R view bag, we're storing the email, to contact you.
Let's go ahead and make this a little bit more
interesting too, so that we don't just see the default theme.
And, we'll scroll up. We'll hit Content.
The site's CSS.
And we'll look for the featured content wrapper.
And we're going to go ahead and set a little gradient here, I think.
We'll go from black The cyan, showing colors
of my commodore days back in my youth.
Black and cyan, some of my favorite.
And that will give it a white text foreground.
We'll save this.
We'll deploy it to our local cloud service.
And you'll see, we now have signups for our newsletter.
We have a little semicolon.
Hold on, let me go back.
Save that, you'll notice how fast, and easy it is to deploy to your local cloud
service environment here, and we're going to go ahead,
and enter an email address here to sign up.
So, we'll go ahead enter Frank Benet's
email address, we'll hit sign up.
And we get our newsletter page saying, thank
you for signing up, with his email address.
So right now, we've set up an MVC4 ASP.NET application in the cloud
as part of a cloud service running as a web role locally in our cloud environment.
Next, we're going to add a worker role.
A worker role is going to go in the background and start
grabbing email addresses for us.