简体   繁体   中英

How to create application with azure, wcf, asp.net and json

I am fairly new to azure, wcf, asp.net and json. I have experience with WPF.

I would like to create a service on the Azure Cloud. There are some demands to this service:

Authentication/ASP.net/Session: When an application, for example a WPF application, WP app/whatever, wishes to use the service, it has to authenticate - and be authenticated for the rest of the session. The authentication is done with windows live id (I guess this is where asp.net comes in?).

WCF: I would like to use a WCF service to expose the methods. How to I "hide" the WCF services from the world, until the user is logged in?

Json: Because I want to use this for (hopefully in the future) WPF apps, WP apps, android apps, iphone apps etc. I would like to use Json.

Azure: I would like to host i all on azure.

For a start, I would just like to create a wpf application with the following:

  1. The user logs in/registeres
  2. The asp.net/wcf authenticates and starts a session. (I don't know how to authenticate)
  3. The user writes a string and passes this with json/http to the WCF service (http will do for now, unless https is easier when authenticating anyways)
  4. The WCF services returns "Hello from azure: " + the string the user wrote

I am very open to suggestions and ideas.

What I need help for is tutorials, walkthroughs, samples, guidance etc. to get me started on this project. I have looked through some tutorials, samples etc., but it is always missing of the components.

Can someone point me in the right direction / offer some advice?

I'd recommend going through some of the Windows Azure tutorials . The main .NET Web App tutorial (linked) shows you how to handle 1 & 2, and the Multi-Tier Application Tutorial covers 3 & 4 fairly well (though I don't believe using JSON). Once you understand that, it should be straightforward to adapt to your needs.

Here is my take on how you can start:

Authentication/ASP.net/Session: - With Azure you can use OpenID based authentication using ACS so look for using ACS on this regard. For ASP.NET session specific requirement you can use Windows Azure Cache which is best and cost effective for such scenarios.

WCF : Good scenario and you can ASP.NET (and/or MVCx) web Role for users to come to your site and then authentication them using OpenID and once authentication you can let them access WCF endpoint or anywere you would want to by setting this in your ACS configuration .

JSON : You sure can use JSON with ASP.NET . You can use jQuery to control the UI and then have it call commands through AJAX/JSON. It also allows you to update a page with new content without having to refresh the page. There could be many more way to use it.

Windows Azure: : Now sure how much you know about Windows Azure but you should have basic knowledge of SDK, Deployment process etc.

Finally you may try something as below:

  1. The user logs in/registeres > ASP.NET MVC Web Role
  2. The asp.net/wcf authenticates and starts a session. >> Use ACS with OpenID
  3. The user writes a string and passes this with json/http to the WCF service > Have an interface for string to be entered at web page and pass it to WCF over HTTP or HTTPS depend on how your bindings are)
  4. The WCF services returns "Hello from azure: " + the string the user wrote

Hope this helps!!

Regarding session state: As I mentioned in this StackOverflow answer, you have multiple options. @Avkash points out one option, to use the Windows Azure Cache. You need to be aware that the cache, being a multi-tenant service, has specific hourly limits on your cache consumption. Depending on user demand / load, you could exceed hourly quota and have no access to cache until the following hour (which means you need to plan for having a larger cache than initially needed). More info on Cache and related quotas, here . Note that pricing begins at $45 for a 128MB cache.

You may also manage session state via SQL Azure. This has no transactional quota, and pricing starts at $4.99 for 100MB. See Nate Totten's blog post about using SQL Azure for session state.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM