Now that we have our cloud service working locally
with both a web role and a worker role, I
want to go ahead and increase the VM count
for the worker role before we push that to staging.
So I'm going to go ahead and set that instance count to 4.
We'll hit Save, we'll run this locally.
And once this is deployed to our compute environment, so
let's show our compute emulator UI, you're going to see a
total of five machines show up.
So you can see here, my web roll is still a single VM,
but my sign ups workers are now
four distinct virtual machines, all processing data.
So you can see here, it's now polling.
As soon as it's ready, you'll see the init will be called.
And then it'll say, processing email.
So we can see signups worker, entry point call.
And then we'll see processing signups, here we go.
So you could see how cool this is.
Is, basically, I've now scaled up my entire worker role infrastructure.
And all of these things will be processing.
And now I can deploy this as a single package.
Out into the cloud.
So let's go ahead and do that right now. I'm going to hit Stop.
We're going to close our worker role.
I'm going to right click on my Cloud service, and I'm going to say Publish.
Now the first thing that's going to happen
is we're going to be asked to go ahead and log in with our credentials.
So let's go ahead and click in, Sign In to download credentials.
It's going to open a browser window.
We're going to Save our credentials to the Desktop.
Now, because I was already logged into the portal, it already had
me logged into my account and knew my published settings to pull down.
We're going to save that to the desktop.
We're going to switch back. We're going to say,
Import > Desktop, and here are my credentials.
This is from our free trial that we set
up earlier in this course so we're going to hit Next.
And we haven't set up any cloud services yet officially in our account.
You remember when we were first creating the cloud service,
we just did a sample one and we deleted it.
So we need a new real service here.
So I'm going to say, Univ, and we'll do this is in West US.
I'll hit Okay.
It's going to check to make sure that's available, and it is.
I have the ability to also switch environments here.
So I'm going to say staging environment.
This is one of the really cool things about a Cloud
service, is, I'm basically moving from a local development environment now.
To an environment out in the cloud that is
in staging, and I can swap environments on the fly.
So I'll be able to say
deploy from staging to production and like
you would expect with a staging environment, when
I go ahead and publish this cloud service, the URL is going to be a staging URL.
So rather than being the univ Cloud service kind
of URL, it's going to create a random URL for us.
We can select a release or debug configuration, and
we can pull from our Cloud or local configuration files.
So if you remember previously in this chapter, I showed
you how you can edit these Cloud service config files so
that you have different settings if you're debugging locally, or
once you've pushed to the Cloud, you can have production settings.
We can also enable remote desktop connections for all roles, or I can hit
Settings here and I can Expire, I can do more Options, do Automatic, Create,
for encrypting my credentials, do all this.
So this will allow us to actually go in and monitor and admin
these machines like we could when I showed you the virtual machines before.
If I go over to Advanced Settings, you'll see I can also label this deployment.
I can choose which kind of storage accounts we want,
and if this deployment doesn't work, I can actually delete it.
If I hit Deployment Update Settings,
what this will do is, it will allow me to do incremental updates.
So we're only going to update our VM's one by one.
If I click Simultaneous update, any new code that I do will
update all of my VMs in the service at the same time.
Let's go ahead and hit Next.
Let's make sure that we have everything setup the way we want.
And you can see we do, in west US.
We are not doing remote desktop or web deploy.
We are set to cloud
configuration and staging.
I am going to go ahead and save this as my staging environment.
So now you'll notice it also has set up an Azure publishing profile.
So in the future I, can just go ahead
and use this profile to do everything automatically for me.
Let's hit publish, and once it's done compiling, it's
going to go ahead and open the Azure publish window.
I'm going to move this publish window up a little bit, so we can see more.
And I'm going to drop
down the little arrow.
So you can see, currently, the environment has a yellow exclamation point.
That means none of this is accessible yet.
It's in the middle of uploading the package,
and you can see the status over here.
It's preparing everything, it's connected, it's verified the storage
account, and right now the website URL is pending.
Once it's reached the point where it's
created a website URL and available, you're going to
see this icon will actually turn to green.
Now we've reached the point where we've actually gone and created the four
instances for our sign ups worker, worker role and our university web role.
You can see that those VM instances are actually stopped.
So it's going to go ahead and start those instances.
Now you'll see that those instances have been created for us.
We have a green button over here and we actually have a website
URL for staging.
At this point, I can switch back into
the Azure portal, and begin looking at my service.
Now remember, what's really cool here is that we're
actually having a Cloud service with five different virtual machines.
Those virtual machines might as well be 5,000.
The deployment process is exactly the same.
We can look at our entire architecture for our service as a single package.
If
I come over here in the Dashboard, and I'm on
Staging Environment, you'll notice now that I have five instances.
All five instances are starting.
Total, I have six of 20.
20 is the limit inside of the free trial.
You remember, we've got one web role, and
we've got five worker roles that are running.
I can also come over here to instances, and I can get individual status on
each instance as it's booting up.
So you'll see here, I've got four signups
worker, worker roles and one web role unit.
Another interesting thing is down here in the command bar, I can actually hit Swap.
So if I click this, you'll see it will move all of the virtual IP addresses, and
it will change the staging environment directly to the production environment.
So this is a very easy way,
once you've tested everything out in staging, to
deploy that automatically to production with one click.
While we're waiting for this to start up, I can also click on
monitor, and you'll see I have CPU percentage for both of those roles.
I can click add metrics, like we have in
the past, and maybe we want to look at disc reads.
You'll notice I have the ability to look at all of the instances, and not just one.
So, I'll turn that on for all. Now, I'm getting information.
Once those are online, you'll actually see the icons.
I can go ahead here and configure.
So, we have the ability to change settings.
You can see we have the ability for
operating systems and what are on those VMs.
I've just set everything to automatic, because I don't
want to have to worry about anything in my service.
I want to just look at this as a piece
of compute power, and not the individual machines behind there.
Let's go back to Visual Studio.
And you'll see now, it looks like some of the worker roles are ready.
And the univ web role is ready.
Now you can see all of the signup worker roles
are ready, as well as the web role being ready.
So you can see, it's created the URL. Status is completed.
If I click on this URL, you can see this is now a live URL in the Cloud.
It's going to take a second for everything to spin up, the first time it's accessed.
And here is our signup page.
We can go ahead and enter our email address and signup, and I have both a
worker role and a web role, all of
those VMs are just deployed through a single click.
If we come back over here into the Dashboard, and
we move over to Instances, you'll now see everything is running.
We can monitor that, so if I come
over here and I generate some traffic, it'll
take a second for all that to come online,
but you'll see all of that traffic is
now available and all part of our staging environment.
We don't currently have anything in production, but again,
moving is as simple as hitting the Swap button.
We've now deployed our entire architecture from our
Local Development Environment, into a Cloud Staging Environment.