Deploy ASP. NET applications that support MVC in azure

Source: Internet
Author: User

(Sorry !)

As someone said before, I'm not quite a cloud guy, but later I came to see a variety of demos and learned about the composition of cloud projects, and someone in mix 09 said "It's fun!" Later, I threw a hello World at this it's fun sentence. I felt pretty good, but I didn't have the motivation to do anything. Then I threw it aside. Google App Engine has been known for almost some time, But Gae monkey can only be used by Ma Yue. NET technology, I do not know Python/Java, and now it seems that gae has nothing to do with workerrole, but it also uses gappproxy, also called Google's cloud.

In this case, there is only one hello World on the cloud of the beloved Microsoft, which is too difficult to say, so I plan to find a period of time to bring all the things I know that can be demonstrated to the cloud, anyway, azure is free now (hopefully the future charging policy will be Gae's current model). It's a pity that you don't need to use it in white. It's a waste of your own beautiful domain names. Well, it's just starting with ASP. net mvc, which is just a few days after release.

 

How to start

Currently, Visual Studio Tools for azure (0903ctp) does not install the so-called MVC webrole template, that is, in the roles-> Add-> New web role project, a template starting with the MVC structure cannot be created, only default. aspx, Web. config:

Apparently not enough. Then we found roles-> Add-> Web role project in solution .. option is unavailable, so the default web role project is deleted and a MVC web application is created to the solution. It is found that this option is still invalid:

In this case, I use the diff tool to compare the MVC project file (C # project is. csproj) and Web role project files, and found that the MVC project file does not have <roletype> Web </roletype> and some points to the azure SDKProgramThe diff tool can be used to reference the set quickly. Reload the modified MVC project file, and choose roles-> Add-> Web role project in solution.

If I created a test project at the beginning, the above process may lead to the loss of reference to the MVC project in the test project, and a prompt will be prompted during compilation. Now, press F5 to debug and wait for a round of initialization. The MVC project's default homepage is displayed. Is this done?

 

Aspproviders & storageclient

Yes, but applications running on azure can have multiple instances, and each instance runs in a different appdomain, distributed in different geographic locations ......), It is isolated, so session-related operations such as login may cause some problems. It is hard to say what the problem is. I have not tried it, but I probably cannot register it, and I cannot remember it. At this time, I was pleasantly surprised to take advantage of Google's strengths. I found four articles related to (1, 2, 4 ).ArticleThe original articles are both in English and are more detailed. There are several other articles from yuanyou (here and here ). Except for the key steps, I will not repeat them.

I am not a computer professional. I have learned a little ASP before and have never learned ASP. net, so many things are known not long ago, such as ASP. NET 2.0 Provider Model. Here, the Provider Model abstracts the storage implementation so that ASP. the various states of. Net can be freely stored in different media, and can be changed through the configuration file. I have to say that this design is really good. The fourth article above (here) describes how to create a membership provider that can run on the cloud.

In the installation directory of the azure SDK, there is a samples.zip containing the aspproviders example provided by Microsoft. This example provides an example of storage media using azure storage as status information, by the way, I also made an example of using storageclient. Haha, I can find a lot of things here. Because many common methods of storageclient do not have a document, supress is given.

 

Rtfm

An important thing in the aspproviders folder is providers-extended-readme.mht. I think this file must be important if you don't plan to write your own providers. SomeCodeHighlighted in red. Unfortunately, the background is gray. After reading the background, you must discard one eye. We recommend that you use word to change the background color to yellow. It looks much more comfortable.

The following is my rtfm summary and I hope it will be useful to you:

  1. Modify web. config to make those providers take effect. Most of the code can be copied from aspprovidersdemo. The appname attribute needs to be modified to the Application name. Delete the inherits attribute of profile. Otherwise, a running error occurs.
  2. Do not set addtional options such as tableservicebaseuri by using the standard deleteheaders in README, because it cannot be modified after being published to the cloud. However, local development storage is used during local debugging.
  3. Modify the. csdef and. cscfg files according to Article 2 during local debugging. Change. cscfg:
     <  Configurationsettings  > <  Setting  Name  = " Defaultproviderapplicationname " Value  = " Yourapplicationname " /> <  Setting  Name  = " Accountname " Value  = " Yourstorageaccountname " /> <  Setting  Name = " Accountsharedkey " Value  = " Yourstorageaccountprimarykey " /> <  Setting  Name  = " Blobstorageendpoint "
    Value = " Https ://Yourstorageaccountname.Blob.core.windows.net "/> < Setting Name = " Queuestorageendpoint "
    Value = " Https ://Yourstorageaccountname.Queue.core.windows.net " /> < Setting Name = " Tablestorageendpoint "
    Value = " Https ://Yourstorageaccountname.Table.core.windows.net " /> < Setting Name = " Allowinsecureremoteendpoints " Value = " False " /> </ Configurationsettings >
  4. Here I have added the defaproviproviderapplicationname. Otherwise, the default appname is used, which is a bit disgusting. Remember to add the corresponding definition to the. csdef file. (One more sentence: How should I declare the metadata myself like the H file in C ++ ......)

 

Some known problems

In my related articles, the following is a simple induction:

    1. Note the additional information of request. URL.
    2. Install this hotfix (a WPF Designer is also fixed)
    3. I don't understand why I want to create test storage tables.

 

Last

It may be because Azure is still in the preview stage. These providers must be configured manually by rtfm. I hope Microsoft will provide the azure MVC webrole Project template and integrate a set of azure aspproviders and storageclient. Then, let some people scold Microsoft for being considerate. Haha! To be honest, although Microsoft seems to be working on JIT all the time, isn't it good? It's so passionate that Microsoft has the motivation ...... Another question ......

In this example, the demo address: http://ccx.cloudapp.net, I will add some applications on it later.

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.