35,99 €
If you are a .NET developer who wants to develop end-to-end RESTful applications in the cloud, then this book is for you. A working knowledge of C# will help you get the most out of this book.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 325
Veröffentlichungsjahr: 2015
Copyright © 2015 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: May 2015
Production reference: 1220515
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78439-837-8
www.packtpub.com
Authors
Alex Belotserkovskiy
Stephen Kaufman
Nikhil Sachdeva
Reviewers
Harsh
Alon Fliess
Harshwardhan Joshi
Commissioning Editor
Kunal Parikh
Acquisition Editors
James Jones
Greg Wild
Content Development Editor
Akashdeep Kundu
Technical Editor
Mrunmayee Patil
Copy Editors
Pranjali Chury
Brandt D'Mello
Project Coordinator
Milton Dsouza
Proofreaders
Stephen Copestake
Safis Editing
Indexer
Monica Ajmera Mehta
Production Coordinator
Arvindkumar Gupta
Cover Work
Arvindkumar Gupta
Alex Belotserkovskiy is a technical evangelist for Microsoft Russia and lives in Moscow. He specializes in cloud, Internet of Things, and high performance computing topics. Alex is actively engaged in both local and international speaking activities, and works with top customers and partners to provide professional technical and technological support for their cloud projects.
Alex was the first Russian Windows Azure Most Valuable Professional, in 2012, and is a Microsoft certified developer and enterprise administrator. He is an experienced Microsoft technologies instructor.
I would like to thank my fiancee, Olga Vilkhivskaya, for putting up with my late night writing sessions and ideas. I would also like to express deep gratitude to Andrey Ivashentsev, Technical Evangelism Unit Lead for Microsoft Russia, without whose efforts this book would not have happened. Alexey Bokov, Technical Evangelist in Microsoft, has my gratitude for continuing to give me valuable experience and advice on how to do things in a better manner.
Stephen Kaufman works for Microsoft as a solution architect in the Americas Office of the CTO and is the lead architect for the US Azure PaaS Center of Expertise (CoE).
He is a public speaker and has appeared at a variety of industry conferences nationally and internationally at events, such as TechEd North America, TechEd EMEA, Microsoft SOA and BPM conference, as well as many internal Microsoft conferences over the years discussing application development, integration, and cloud computing, as well as a variety of other related topics.
Stephen is also a published author with two books—Pro BizTalk 2009 (http://www.apress.com/book/view/1430219815) and Pro Windows Server AppFabric (http://www.apress.com/book/view/1430228172), both by Apress Publishing—as well as a number of whitepapers and other published content, including a blog at http://blogs.msdn.com/skaufman.
In addition, he is a board certified architect (CITA-P-IASA Global) and continues to work mentoring and sitting on architecture certification review boards.
Lastly, Stephen was a contributing author for the Azure Architecture Certification Exam 70-534, Architecting Azure Solutions.
Nikhil Sachdeva is a senior consultant at Microsoft. He has over 11 years of experience in architecting and implementing scalable web applications and services using Microsoft technologies. He has been involved with Microsoft Azure since its early days and currently works as a subject matter expert in building custom Platform as a Service (PaaS) solutions on the Azure platform. He has a passion for writing and is a contributing writer for Introducing Windows Azure for IT Professionals, Microsoft Press, and has contributed to several other Microsoft articles and blogs on Microsoft Azure and related technologies. His recent passion is building highly scalable and available solutions for the Internet of Things (IoT) and frequently rants his experiences at http://connectedstuff.net.
I would like to thank my beautiful wife, Pratibha, for encouraging me to pursue my passion for writing and supporting me throughout the process. Thanks for being my support system, my buddy, my critic, and for giving me the best gift of life, our newborn son, Ayansh. A special thanks to the team at Packt Publishing for their continuous support and patience.
Harsh works as a software engineer for Microsoft. He has worked on quite a few things and he feels that it still hasn't been enough for his exploration and he should keep trying new technologies and keep learning.
Besides his interest in cloud computing (read Azure) and programming in general, he likes reading and fiddling with CTF questions and ciphers. He started the HackCon (Build the Shield) event in Microsoft, which is Microsoft's version of Capture the Flag events. He is also a moody blogger and tries to keep his portfolio up to date. You can find him at http://hars.in.
I would like to thank my friends and colleagues from whom I learn every day.
Alon Fliess is the chief architect and founder of CodeValue. He got his BSc degree in electrical and computer engineering from Technion, the Israel Institute of Technology. He is also recognized as a Microsoft Regional Director (MRD). He is an expert in many technologies, be it Windows internals, C++ Windows programming (Win32/WinRT), .NET with C#, Windows Azure Cloud Computing, or Internet of Things (hardware and software).
Alon spends his time doing many interesting tasks such as software architecting, designing, mentoring, and programming. He is the author and technical reviewer of several computing books. Alon is an active member of several Patterns & Practices councils, among them is project Hilo—a Windows Store Application in C++/CX and XAML.
He is one of the experts in the Microsoft Israel community. He helps Microsoft clients in many technological aspects. He gives lectures at Israeli and international conferences, such as NDC, CVCon, TechEd, and more.
To Deepti Thore, who gave me the chance to review this book, and to Milton Dsouza, who had the patience to wait for me to complete the review—thank you both.
To my beloved wife, Liat, and my three children, Yarden, Saar, and Adva, thank you for all your understanding and support.
Harshwardhan Joshi lives and works in Pune and loves spending time with his wife, and pet cat named "Hulk". He calls himself "a Cloud engineer who writes APIs for a living". He has been passionately working on several Microsoft technologies from .NET Framework, Microsoft Silverlight, WF, and WCF to Microsoft Azure for the last 7 years and has worked on creating several exciting products. He has been working on Microsoft Azure since its inception. He currently works with RapidCircle as a Cloud Consultant. In his previous stint with Icertis, he was one of the core members responsible for building highly scalable, always available, and high performance APIs on Microsoft Azure.
You can meet him at events organized by the Pune User Group, a group for avid developers in Microsoft Technologies in Pune. He stays updated on the latest cars and engines hitting the market. He is a regular contributor to the Team-BHP forum. He can also be found on Twitter at @hjoshi.
Thanks to Packt Publishing for this amazing opportunity to review this book on Microsoft Azure. I hope you all enjoy reading this book as much as I enjoyed working on it. I would also like to thank my family and friends for being extremely supportive.
For support files and downloads related to your book, please visit www.PacktPub.com.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at <[email protected]> for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.
If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view 9 entirely free books. Simply use your login credentials for immediate access.
With multiple cloud platforms out there, it is easy to get confused when making a technology decision for your projects. This gets further complicated with the plethora of development tools and frameworks available today. Microsoft Azure simplifies this problem by providing a scalable and manageable platform for customers to easily deploy, monitor, and troubleshoot their cloud-based applications. Its seamless integration with new and existing Microsoft tools and inherent support for open source software makes it an obvious choice for building cloud-based applications and services.
Whether you are new to Microsoft Azure cloud development or you have been creating cloud applications, there will be something new for you in this book. We will cover the full application development architecture and cover all tiers of an application. We will also cover a number of patterns that you will encounter, from solutions that are completely hosted in the cloud to hybrid solutions where applications are split between the cloud and on-premises networks.
Chapter 1, Getting Started with the ASP.NET Web API, introduces the ASP.NET Web API framework and provides an overview of its application and internals. It will guide you through the stages of creating a Web API and deploying it in Microsoft Azure.
Chapter 2, Extending the ASP.NET Web API, discusses various extensibility and customization options available in the ASP.NET Web API framework. It guides the reader through various extension points, such as custom routing, message formatters, content negotiation, and securing a Web API. It also discusses various hosting options for deploying Web APIs.
Chapter 3, API Management, provides a set of tools that assist API developers in managing and monitoring Web APIs. We will discuss various options of publishing, marketing, monitoring, and managing a Web API using API management.
Chapter 4, Developing a Web API for Mobile Apps, provides an overview of Mobile Services and walks through a scenario of creating a Web API using Mobile Services. Mobile Services provides an easy-to-use environment to rapidly build cross-platform apps for Windows, iOS, Android, and other platforms. Its rich built-in capabilities for managing backend login, data, authentication, and notifications makes it a compelling option for developing mobile applications.
Chapter 5, Connecting Applications with Microsoft Azure Service Bus, discusses Windows Azure Service Bus, which allows for related and brokered messaging using a range of different features (such as Topics and Queues).
Chapter 6, Creating Hybrid Services, demonstrates how to create Hybrid Services to connect on-premises Large Object (LOB) / database to cloud-based applications. Essentially, this chapter builds on the previous chapter, demonstrating how you can use the elements of the Service Bus to create Hybrid applications. It will also demonstrate how to effectively maintain these applications.
Chapter 7, Data Services in the Cloud – an Overview of ADO.NET and Entity Framework, explores how to create data services in the cloud using Entity Framework and ADO.NET.
Chapter 8, Data Services in the Cloud – Microsoft Azure Storage, explores how you can use cloud-based Azure Storage technologies.
Chapter 9, Data Services in the Cloud – NoSQL in Microsoft Azure, explores how to use DocumentDB, a fully managed, highly scalable NoSQL data management service based on Azure, as well as ways to start using other open source Azure options such as MongoDB.
The hardware requirements are as follows:
The software requirements and their download or purchase sources are mentioned in the following list:
Note that the samples have only been tested on Visual Studio 2013 and not on Visual Studio 2015 preview.
If you are a developer or an architect who wants to develop end-to-end RESTful applications in the cloud, then this book is for you. You will need professional knowledge of C# to work through the projects in this book.
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.
To send us general feedback, simply e-mail <[email protected]>, and mention the book's title in the subject of your message.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.
To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.
Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <[email protected]> with a link to the suspected pirated material.
We appreciate your help in protecting our authors and our ability to bring you valuable content.
If you have a problem with any aspect of this book, you can contact us at <[email protected]>, and we will do our best to address the problem.
HTTP 2.0 is the next planned version of the HTTP protocol specification and is an attempt to optimize the usage of network resources and reduce latency through header compressions and pooling multiple connections over the same channels. The initiative is spearheaded by Google and Mozilla research teams and as of today, is in a working draft state. The good news is that HTTP 2.0 is going to retain all the goodness of HTTP 1.1 while making it more performant over the wire through efficient processing of messages. Since HTTP 2.0 is still in the making, we will refrain from using it for the scope of this book. However, if you are enthusiastic to know more about HTTP 2.0, you can take a look at the current draft of the specification at http://http2.github.io/http2-spec/.
For the scope of this book, HTTP always refers to HTTP 1.1 specification of the protocol.
Starting from .NET 4.5, a new namespace and assembly was added as part of the framework, System.Net.Http. The resemblance of the types in this namespace may look behaviorally similar to those defined in ASP.NET System.Web.Http namespace; however, the addition of this namespace marks a big difference in the development of HTTP services.
Firstly, it enables unified communication over HTTP by providing a set of abstract types. These types allow any .NET application to access HTTP services in a consistent way, for example, now both the client and server can use the same HTTP programming model for better development experience. Secondly, it has been written to target modern HTTP apps such as Web API and mobile development, this signifies the investment of Microsoft in making HTTP services a first-class citizen.
Some of the key types defined in this namespace are:
Type
Description
HttpClient
This enables primitive operations for sending HTTP requests and receiving HTTP responses from a resource identified by a URI.
HttpRequestMessage
This represents the HTTP request message from a client.
HttpResponseMessage
This represents the HTTP response message received from an HTTP request.
HttpContent
This is a base class that represents an HTTP entity body and any content headers.
HttpMessageHandler
This is the base type for all message handlers and this will be used to define all message handlers. Message handlers may be used to create server-side or client-side handlers.
The server-side handler works with the hosted model chain and handles incoming client requests (HttpServer and HttpSelfHostServer). It determines the correct route for the request (HttpRoutingDispatcher) and dispatches the request to the controller (HttpControllerDispatcher).
The HttpClient type uses client-side message handlers to process requests. The default handler HttpClientHandler is responsible to send the request and get the response from the server.
We may, of course, hook our custom controllers in the pipelines, for example, to validate, modify, or log the requests.
For a complete list of all types available in the System.Net.Http namespace, please visit http://msdn.microsoft.com/en-us/library/system.net.http(v=vs.110).aspx.
We will see in the later sections that the ASP.NET Web API also leverages some of the System.Net.Http types for communication over HTTP.
When talking about Web APIs, it is imperative to mention the REST framework. Over the years, REST has proven to be a much simplified and efficient web service architecture style as compared to other architectures like RPC-based SOAP. The key reason for this popularity is because of its modern web design patterns and utilization of HTTP transport layer features to the fullest. REST has enabled many modern-world scenarios such as Mobile apps and Internet of Things (IoT), which would be challenging with protocols like SOAP because of its rigid schema-based WSDL structure and bulky XML standards.
A good comparison of REST and SOAP protocols can be found at http://blog.smartbear.com/apis/understanding-soap-and-rest-basics/.
REST stands for Representational State Transfer and perhaps the most important thing to realize about REST is that it is an architecture style and not a standard (like SOAP). What do we mean by this?