Deploying a WCF application in Windows Azure - c#

I'm looking for some advise / best practices for setting up a WCF application in Windows Azure.
Currently I have an SQL Azure DB and I want to make some services which need to provide information for iPhone and some other 3rd party products.
1) How do I develop a WCF application in Windows Azure, using SQL Azure data?
2) What is the best architecture to do this and what is the best way to make this secure?
I'm using C# as language.

You can create the WCF Web Role by using the Azure SDK, or you can host your WCF on a worker role as well. It's up to you.
Connect to SQL Azure would be very very similar as what you did to connect to SQL Server, just pay attention to the connection string.
Since you mentioned this WCF will be used for iPhone and some 3rd part application, I strongly recommended you have a look on WCF RESTful Toolkit, and the JSON format. Since for this scenario, RESTful API (or web api) with JSON format would be the best.

Take a look at this post 'Building a Massively Scalable Platform for Consumer Devices on Windows Azure'
http://msdn.microsoft.com/en-us/magazine/hh781021.aspx
Should cover your two topics nicely...
Connecting to SQL Azure is easier, you have so many options, ADO.NET, Entity Framework, OData etc..
http://msdn.microsoft.com/en-us/library/ee621789.aspx
Take a look at the Windows Azure Training Kit for more sample on this.

Related

Getting a web service and using android to consume them?

I have been looking up on youtube regarding Web Services being consume using android. Most of the video are all 1 or 2 years old. Is this doing outdated? is there a better way to do this? currently i am in a company and i was assign to have a android version of their webservice.
I was told to create the service with sql using Visual studio.
Create the android UI and using the services to pull the data.
Am i doing it right?
What is the better or ideal way of going about this?
Should i add JavaScript or something like that?
I have been looking at RESTful , Soap , Json and Wcf. But what is the best way to go if i have to start everything from scratch?
-Programs/System that i am using.
Microsoft Visual Studio Express 2013 for Web
SQL server
IIS express
Android Studio
*I was told to only user framework 4.0 for Visual studio
You can use WCF (SOAP), WCF (RESTful) or WebApi to create a service, both has it's own advantages and disadvantages. You may want to take some time to look at your requirement and then decide what type of service you want to develop. SOAP uses a more complicated messaging pattern using XML, where as REST uses the standard HTTP protocol and methods to communicate and transfer data. But if you are planning consume this service across of variety of applications like mobile, web, desktop, client side script interaction etc, you may consider developing the service as a RESTful. More information on SOAP and RESTful and for detailed understanding you may refer to this link
Understanding SOAP and RESTful

Build JSON REST api/webservices in vs2010 or vs2012 that will consumed by ajax clients in mobile devices

I have an Existing Web application builded two years ago with VS2010 ASP.NET Web Forms, C# and SQL SERVER 2008 .Now i want to build mobile version and install it in mobile devices. I want to develop it using JQuery Ajax, Jquery Mobile and Apache Cordova. My simple question is how can build serialize from database json REST api/webservices in vs2010 or vs2012 that will consumed by ajax clients in mobile devices ???
Thanks to all
I would recommend you for WebAPI. because of following reasons.
If we need a Web Service and don’t need SOAP, then ASP.Net Web API is best choice.
It is Used to build simple, non-SOAP-based HTTP Services on top of existing WCF message pipeline.
It doesn't have tedious and extensive configuration like WCF REST service.
Simple service creation with Web API. With WCF REST Services, service creation is difficult.
It is only based on HTTP and easy to define, expose and consume in a REST-ful way.
It is light weight architecture and good for devices which have limited bandwidth like smart phones.
It is open source.
Tutorial is here.
http://channel9.msdn.com/Events/Build/2014/3-603
Save yourself a lot of coding, and use SlashDB. http://www.slashdb.com/how-it-works/
It will automatically make a web API for an existing database. Your case is very typical because many websites use server-side templates to make dynamic HTML, which of course does not work well if you need a native app or a highly responsive HTML5 mobile page.
Disclosure: I am the founder and CEO of the company behind SlashDB, but you don't have to take my word it - just try it.

HTML5 with .NET backend App, compatible with both standalone Windows and Azure?

I need to design an HTML 5 responsive, and simple app that should work on both internal Win server and on Azure.Our Client wants to check out Azure but maybe later he will want this app to be on its own on premise servers. Our Developers are almost all .NET back ends, with basic knowledge in HTML 5, Javascript, Jquery, and bootstrap. We accepted the challenge because the project is tiny and interesting, the point is, is possible to have 1 project that can be deployed to azure or IIS with no problem? and what kind of project should we create? I think that a simple asp.net project with some web methods and js will do the job, but I don't know if it will work on azure too. Back n 2010 I did something that way but now I am not sure it's still valid
Important: the web application should be able to query oracle on premise server, via web service but not sure if take azure service bus or azure vpn
It depends on how you build your application. I have built applications in the past that works both on-premise and on Azure. As long as you don't access any Azure specific features, there's no problem to deploying the web application project to an on-premise IIS.
If you use Azure-specific features or services from Azure, such as Azure SQL DB, you have to built an on-premise version. In my case it was simple as changing the connection string and the rest was done by Entity Framework, but you can use an IoC container, such as Unity, to change your implementation based on the environment you're running on. If the Azure environment is available (check through RoleEnvironment.IsAvailable) you resolve the Azure-specific implementation of some features and if not the on-premise implementation. In most cases that are just a few dependencies, for example if you use a worker role on Azure and a Windows Service on-premise.

Good way of communicating between web and desktop app

I want my web app (running in a browser) to, at some point, communicate (bidirectionally) with a desktop app (in Windows), the client has installed in its computer.
What's an elegant and modular and simple way of doing this (with Java and C#)?
Not much information will be passed between the web app and the desktop app. Just something like "I was here", "Pick this from this point", etc.
I solved that problem by using a database on the network.
All communications where made trough the database.
Website -> DB -> User logged in <- DB <- Desktop
However, if no trusted information needs to be shared, you could consider just posting and reading some http headers to a common website, or a simple log file.
Greetings
I suggest you to use the backend part of your webapp, assuming that your app is based on some backend services.
You have two options:
Your desktop apps use the same services of your web app. You must use a class that mimic a web-browser to give the data (curl, ie). If your web app is based on AJAX push ( APE Server i.e ) use library that is able to run some javascript
Use a REST protocol, with a JSON format in your backend services. It's easy to manage and is supported by many client-side languages (java/c#/python....)
Use a specialized endpoint only for your desktop app,for C#, you can use WCF, that allow you, in one of his forms bidirectional communications. For JAVA, there are WSDL, DWR
My preferred solution is to decouple the web app in a front-end side and a backend side, that expose the services as REST that are used by the web app via AJAX.
If I need true bidirectional communication with other desktop app, I'll create a separate service / endpoint for it. (APE , WCF, ..)
I see several options to achieve part of what you are asking:
Besically you expose the relevant parts of your apps (web and desktop) via some sort of API and use that for the communication - for example DB and/or WCF (SOAP/REST/whatever).
BEWARE:
If you are after some sort of direct/interactive communication between both apps on the same computer then this won't be possible - at least not without some security related issues.
The browser executes your web app in a sandbox which doesn't allow for direct communication between the web app and the desktop... there are technologies which can help circumvent that (ActiveX, signed Java applets, some Flash technology called AIR etc.)... or you could host some webbrowser/control in your desktop app which in turn runs the web app... BUT basically I would recommend against using any such measures...
IF you really want to go this route then please describe your environment and goal with much more detail.

What is the preferred method for building web services in .Net?

I am confused as to what is the best method for building a web service in .net. Giving the fact that it needs to be highly scalable. Any suggestions?
If your consumers are all .NET, look at WCF:
http://msdn.microsoft.com/en-us/library/ms731082.aspx
Otherwise, plain old SOAP services are good. Both are scalable.
IIS is designed for scalability, so I'd definitely consider using ASP.NET web services rather than hosting my web service within a windows service using WCF.
Of course, you can host your WCF web service within IIS. Here's an article on how to do this.
This article is a little old, but it details the benefits of hosting your web service in IIS within the Recommendations section:
Scalability—It is very easy to scale out a Web service using load-balancing technology such as Windows Network Load Balancing, or hardware devices from vendors such as Cisco and F5. More on this subject to follow.
Availability—ASMX Web services can be configured to be highly available using a combination of technologies such as load-balancing combined with the powerful capabilities of the IIS6 infrastructure built into Windows 2003 Server (such as automatic recycling and restarting of failed services).
I guess the point is no matter if you want to use ASP.NET web services or WCF, definitely host it in IIS.
We use WCF. You can also use Spring.Services very powerfull framework.
What stragedy you whant to use service-first or contract-first?
As per as i know it totally depend on the what kind of web services u want to develop....
if u want to secure,state management and other facilities that can be required for web services ....i prefer WCF (Window communication foundation).
The global acceptance of Web services, which includes standard protocols for application-to-application communication, has changed software development. For example, the functions that Web services now provide include security, distributed transaction coordination, and reliable communication. The benefits of the changes in Web services should be reflected in the tools and technologies that developers use. Windows Communication Foundation (WCF) is designed to offer a manageable approach to distributed computing, broad interoperability, and direct support for service orientation.
for more information about and Problem Example
Use WCF.
It allows you to expose a service using multiple protocols and multiple security contexts.
A very good resource for learning WCF is Michele Bustamante's book Learning WCF.
http://www.amazon.com/Learning-Hands-Michele-LeRoux-Bustamante/dp/0596101627
Note: If you do get this book, she has an updated version of Chapter 1 and an appendix on her website.
Her website is also a good source of up-to-date information: http://www.dasblonde.net/default.aspx

Categories

Resources