次の方法で共有


Creating an On Premise Database and MVC Web Application and Migrating to Windows Azure and SQL Azure-Step 7 of 10

Previous Posts that you should review

bullet

Step 1
hyperlink[6]

https://blogs.msdn.com/b/brunoterkaly/archive/2010/06/12/creating-an-on-premise-database-and-mvc-web-application-and-migrating-to-windows-azure-and-sql-azure-step-1-of-10.aspx

bullet

Step 2
hyperlink[6]

https://blogs.msdn.com/b/brunoterkaly/archive/2010/06/11/creating-an-on-premise-database-and-mvc-web-application-and-migrating-to-windows-azure-and-sql-azure.aspx

bullet

Step 3
hyperlink[6]

https://blogs.msdn.com/b/brunoterkaly/archive/2010/06/27/creating-an-on-premise-database-and-mvc-web-application-and-migrating-to-windows-azure-and-sql-azure-step-3-of-10.aspx

bullet

Step 4
hyperlink32

https://blogs.msdn.com/b/brunoterkaly/archive/2010/06/28/creating-an-on-premise-database-and-mvc-web-application-and-migrating-to-windows-azure-and-sql-azure-step-4-of-10.aspx

bullet

Step 5
hyperlink31

https://blogs.msdn.com/b/brunoterkaly/archive/2010/06/28/creating-an-on-premise-database-and-mvc-web-application-and-migrating-to-windows-azure-and-sql-azure-step-5-of-10.aspx

bullet

Step 6
hyperlink

https://blogs.msdn.com/b/brunoterkaly/archive/2010/06/30/creating-an-on-premise-database-and-mvc-web-application-and-migrating-to-windows-azure-and-sql-azure-step-6-of-10.aspx

Moving our MVC app to the cloud

Creating a “Cloud Project” At this point we have a running on-premise MVC application that gets data from SQL Azure (cloud based relational storage).Here is what this blog post will cover

bullet

New Azure Project

bullet

Adding an "MVC 2 Web Role"

bullet

Understanding Instance Count and VM Size

bullet

Connecting our new Cloud Project to the DataLayer

bullet

Changing the .NET Framework version for the DataLayer

bullet

Implementing the Connection String

snap0147

Windows Azure Project 

Note the Cloud templateSelect the Windows Azure Cloud Service.

snap0148

Choosing a web role 

Select MVC Web roleFor the post, we are talking about MVC Web Role.

snap0149 snap0150

Naming your web role 

Changing the default nameClick on the icon of the pencil to change the name of the web role. We will name our web role as MvcAzure_WebRole

snap0151

Unit Tests

Unit tests have value, but are beyond the scope of this post

bullet

Unit testing is a software verification and validation method in which a programmer tests if individual units of source code are fit for use

bullet

A unit is the smallest testable part of an application

bullet

For MVC apps, a unit may be an individual function or procedure

bullet

Unit tests are typically written and run by software developers to ensure that code meets its design and behaves as intended

snap0152

Not one, but 2 projects have been added 

Why 2 projects?

bullet

The first project (MvcAzure) is your configuration project. More on this later.

bullet

The second project is the Azure-based MVC project. We will make our modifications to the code base here in MvcAzure_WebRole.

snap0153

How to configure your Azure MVC Application

Double-click on “MvcAzure_WebRole” In order to change the configuration of your application, double-click on MvcAzure_WebRole

snap0154

Instance Count & VM Size 

Changing Configuration settingsDouble clicking on MvcAzure_WebRole brings up the configuration windows you see below.

snap0155

A note about limits 

Understanding VM Size and Instance Count

bullet

The number of CPU cores for a role is the Instance Count

bullet

If you add those up across all of your roles across all of your Hosted Service projects (staging and production slots) – this has to be lower than 20

bullet

Quick example: if you have 5 Hosted Service projects with 1 role, 2 instances per role and Medium VM size, you’ve hit the limit

bullet

The other key is that you not only need to stop your deployment to free up CPU cores, you also need to delete the deployment to reduce your CPU core count

bullet

You can read more about this here:https://azurefeeds.com/post/900/Windows_Azure_Instance__Storage_Limits.aspx

snap0156

Setting up references – same as before 

MvcAzure_WebRoleThis exact process was performed for the on-premise MVC application.

snap0157 snap0158

The DataLayer needs to be built upon version 3.5 of the .NET Framework 

Azure only supports version 3.5 currentlyThe upgrade to 4.0 of the .NET Framework will happen any day now. In the meantime, you’ll need to “downgrade” to version 3.5.

snap0159 snap0160 snap0161

Still need to add a reference for System.Data.Entity 

Right mouse click on MvcAzure_WebRoleAdd a reference and then be prepared to “Copy Local”

snap0162   snap0165 snap0166 snap0167

Managing Connection Strings 

Copy the connection string to MvcAzure_WebRoleWe did this exact step in a previous post:
hyperlink[1]

https://blogs.msdn.com/b/brunoterkaly/archive/2010/06/11/creating-an-on-premise-database-and-mvc-web-application-and-migrating-to-windows-azure-and-sql-azure.aspx

snap0169

 

Next Blog Post is about…

Steps in the next blog post

bullet

Copying the controller code from the on-premise MVC application to the cloud-based MVC application

bullet

Copying the view code from the on-premise MVC application to the cloud-based MVC application

bullet

Copying the connection string code (may be a duplicate step)

bullet

Running the cloud-based MVC application locally on the development fabric