AutoCAD command to measure the implementation process of magic Magic Ball-(3)

Source: Internet
Author: User
Tags windows azure sdk azure sdk

 

In the previous article (first and second), I have created a RESTful service program, used JQuery to obtain data from the server, and then used ThreeJs to render the magic ball. However, this program is still running on a local machine, and the data is stored in the local SQL Express, which is a common ASP.net application, and the relationship with cloud computing is not even half a cent. This article will move this application to the Windows Azure cloud.

Connection: http://www.cnblogs.com/junqilian/archive/2013/03/19/2969443.html

 

In fact, this process is not complex. The Windows Azure SDK can make this process very simple. Porting an ASP.net application to the cloud is a little more complicated if you use a Session. After all, the cloud is no longer a server but many servers. If the in-proc method is used to save the session, there will be a problem when porting the session to the cloud. You can save the session and other status information in Azure storage or SQL Azure database, or use App Fabric. However, this example is simple. My service only provides stateless REST services, so you do not need to consider the status saving issue.

First, add a project to the solution and select the "Windows Azure Cloud Service" template:

The next page is to add a Web Role. do not add anything here, because my existing ASP.net application will be used as my Web Role in the future, and press the OK button directly:

Then, Add the Web Role. Right-click the Roles directory and choose Add-> Web Role Project in solution. Select My current ASP.net MVC application and make this Web Role:

You can edit a Web Role attribute, such as the number of server instances. The default value is 1. The production environment must contain at least two. I will not change it here. Okay, that's easy. You have migrated to the cloud! However, it is still running in your local cloud simulation environment. You can press F5 to run it in the cloud simulator to see if there are any problems, now we can release it to the real Windows Azure cloud environment.

 

Before starting, let's take a look at the data. Now, my data is stored in the local SQL Express. If you want to port a program to the cloud, data must be migrated to the cloud. The simplest is to use SQL Azure cloud database. First, log on to the Windows Azure console Windows Azure Management console to create SQL Azure. choose New> Data Services> SQL DATABASE> CUSTOM CREATE. windows Azure has a Chinese interface. When I write an english blog, I changed it only when foreigners do not know Chinese :)

Then you know the name of a database. If you have not created an SQL database server, you can create a new database server.

To create a database server, you must specify the login name and password. Then you need to know where the Region is located. When you select region, you 'd better select a region with the cloud service you are about to release. This has better performance and no additional costs. Region should select the one close to the customer. For example, if I expect most of my customers to be in China, I will select East Asia.

 

After creating the SQL database, you can start to port the database. If you have a lot of data locally, you can use the script generation method. You can use SQL Server 2008 Management Studio to connect to the local database to generate database scripts (Be sure to select the real SQL Azure generation script), connect to SQL Azure, and run the generated script on it. I will not introduce this process here, because I have all the test data here, and these test data are generated by code in the initialization age. I can directly change the connection character to SQL Azure to complete this process. However, you need to set up a firewall on the Azure console to run the current IP address to connect to the SQL server. This process is also required if you want to connect to SQL Azure with SQL Server 2008 Management Studio. Log on to the Azure console and select your database. You can click Set up windows Azure firewall for this IP address on the following page.

 

Then, as mentioned above, you need to change the connection string to connect to SQL Azure. What is the connection string? Click "View SQL Database connection strings" above to see:

Replace it with web. config. Do not forget to enter the password:

  <connectionStrings>
    <!--<add name="AcadCommandViewerContext" connectionString="Data Source=.\SQLEXPRESS;
Initial Catalog=AcadCommandViewerContext; Integrated Security=True;
MultipleActiveResultSets=True"
      providerName="System.Data.SqlClient" />-->
    <add name="AcadCommandViewerContext" connectionString="Data Source=tcp:qmhqjrmav7.database.windows.net,1433;
Initial Catalog=acadcmdviewer;User Id=<sql server user id>;Password=<input your password>;"
  providerName="System.Data.SqlClient" />
  </connectionStrings>

 

Because I am using Entity Framework, now I can install the original method to generate my database and initialization data again in SQL Azure. Go to the Package Manager Console from Tools> Library Package Manager and run the Update-Database command.

PM> Update-Database

 

Now, you can deploy the application to the cloud. The Windows azure SDK provides easy-to-use tools. Right-click the Azure project and select publish to start the Publishing Wizard:

 

I use MSDN subscription:

Create a new cloud service and select the same region as the preceding SQL azure:

Follow the wizard. I will use the default settings here. Then wait for a pack of cigarettes to complete the release process. You have successfully moved your ASP.net application to the cloud!

Now let's talk about the data source of the magic ball and the creation of the AutoCAD plug-in.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.