Microsoft Windows Server AppFabric Cookbook - Hammad Rajjoub - E-Book

Microsoft Windows Server AppFabric Cookbook E-Book

Hammad Rajjoub

0,0
47,99 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

Windows Server AppFabric provides a set of integrated capabilities that extend IIS and the Windows Server platform making it easier to build, scale and manage composite applications today. Windows Server AppFabric delivers the first wave of innovation within an exciting new middleware paradigm which brings performance, scalability and enhanced management capabilities to the platform for applications built on the .NET Framework using Windows Communication Foundation and Windows Workflow Foundation.'Microsoft Windows Server AppFabric Cookbook' shows you how to get the most from WCF and WF services using Windows Server AppFabric leveraging the capabilities for building composite solutions on the .NET platform. Packed with over 60 task-based and immediately reusable recipes, 'Microsoft Windows Server AppFabric Cookbook' starts by showing you how to set up your development environment to start using Windows Server AppFabric quickly. The book then moves on to provide comprehensive coverage of the most important capabilities provided by Windows Server AppFabric, diving right in to hands-on topics such as deploying WCF and WF applications to Windows Server AppFabric and leveraging the distributed caching, scalable hosting, persistence, monitoring and management capabilities that Windows Server AppFabric has to offer, with recipes covering a full spectrum of complexity from simple to intermediate and advanced.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB
MOBI

Seitenzahl: 398

Veröffentlichungsjahr: 2012

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Table of Contents

Microsoft Windows Server AppFabric Cookbook
Credits
Foreword
About the Authors
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Instant Updates on New Packt Books
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Installing Windows Server AppFabric
Introduction
Installing Windows Server AppFabric
Getting ready
How to do it...
How it works...
Configuring Windows Server AppFabric (hosting and monitoring)
Getting ready
How to do it...
How it works...
Configuring Windows Server AppFabric (caching)
Getting ready
How to do it...
How it works...
Installing Cache Client Assemblies
Getting ready
How to do it...
How it works...
Changing the Windows Server AppFabric configuration after installation
Getting ready
How to do it...
How it works...
Starting a Caching service
Getting ready
How to do it...
How it works...
Troubleshooting Windows Server AppFabric — configuration errors
How to do it...
How it works...
Troubleshooting Windows Server AppFabric — auto restart issues
How to do it...
How it works...
2. Getting Started with AppFabric Caching
Introduction
Initializing Cache Client using code
Getting ready
How to do it...
How it works...
See also
Initializing Cache Client using configuration
Getting ready
How to do it...
How it works...
Programming AppFabric Cache Client
Getting ready
How to do it...
How it works...
Using AppFabric Cache via the ASP.NET provider model
Getting ready
How to do it...
How it works...
Using AppFabric local cache
Getting ready
How to do it...
How it works...
Using the AppFabric cache management tool
Getting ready
How to do it...
How it works...
Building a custom provider model
Getting ready
How to do it...
How it works...
Handling common Windows Server AppFabric caching errors
RetryLater
TimeOut
ConnectionTerminated
Getting ready
How to do it...
How it works...
There's more...
3. Windows Server AppFabric Caching — Advanced Use Cases
Introduction
Using regions in cache
Getting ready
How to do it...
How it works...
There's more...
Using tags in cache
Getting ready
How to do it...
How it works...
Using optimistic concurrency
Getting ready
How to do it...
How it works...
There's more...
Using pessimistic concurrency
Getting ready
How to do it...
How it works...
Setting up expiration
Getting ready
How to do it...
How it works...
There's more...
Setting up eviction
Getting ready
How to do it...
How it works...
Setting up notifications
Getting ready
How to do it...
How it works...
There's more...
Using performance counters
Getting ready
How to do it...
How it works...
There's more...
See also
Troubleshooting throttling
How to do it...
How it works...
Troubleshooting eviction
How to do it...
How it works...
Setting up read through — write behind
Getting ready
How to do it...
How it works...
There's more...
4. Windows Server AppFabric Hosting Fundamentals
Introduction
Installing the Web Deployment tool (Web Deploy)
Getting ready
How to do it...
How it works...
There's more...
See also
Packaging services for deployment with Web Deploy
Getting ready
How to do it...
How it works...
There's more...
Deploying a package from the command line
Including SQL artifacts in your deployment
See also
Hosting WCF services
Getting ready
How to do it...
How it works...
There's more...
See also
Hosting WCF REST services
Getting ready
How to do it...
How it works...
There's more...
Where's my XML?
Extension-less caveats
Advanced conditional HTTP GET caching support
See also
Hosting basic workflow services
Getting ready
How to do it...
How it works...
There's more...
See also
5. More Windows Server AppFabric Hosting Features
Introduction
Hosting long-running workflow services
Getting ready
How to do it...
How it works...
There's more...
More on persistence
Understanding correlation
Understanding the Workflow Management Service
See also
Taking advantage of WAS and Auto-Start
Getting ready
How to do it...
How it works...
There's more...
Avoiding application pool recycling
See also
Hosting Windows Azure Relay services
Getting ready
How to do it...
How it works...
There's more...
See also
Using common Server AppFabric hosting commandlets
Getting ready
How to do it...
How it works...
There's more...
Remote management
See also
6. Utilizing AppFabric Persistence
Introduction
Durable application scale out
Computational resources
Using Windows Server AppFabric workflow persistence
Getting ready
How to do it...
How it works...
There's more...
Programmatically querying persisted workflow instances
Getting ready
How to do it...
How it works...
Execute Query
There's more...
Execute Count
Execute Group Count
Programmatically controlling persisted workflow instances
Getting ready
How to do it...
How it works...
There's more...
Developing an Instance Store provider
Getting ready
How to do it...
How it works...
There's more...
Developing an Instance Query provider
Getting ready
How to do it...
How it works...
There's more...
Developing an Instance Control provider
Getting ready
How to do it...
How it works...
Registering and configuring custom store, query, and control providers
Getting ready
How to do it...
How it works...
There's more...
7. Monitoring Windows Server AppFabric Deployment
Introduction
Collecting events from WCF and WF services
Getting ready
How to do it...
How it works...
See also
Viewing and classifying events in the AppFabric Dashboard
Getting ready
How to do it...
How it works...
There's more...
See also
Enabling tracing and evaluating trace logs with WCF
Getting ready
How to do it...
How it works...
See also
Creating a customized tracking profile for WF services
Getting ready
How to do it...
How it works...
There's more...
See also
Accessing the Monitoring DB
Getting ready
How to do it...
How it works...
See also
Building a custom dashboard
Getting ready
How to do it...
How it works...
There's more...
Consuming monitoring data from Microsoft Excel
See also
Using monitoring database cmdlets
How to do it...
How it works...
There's more...
See also
Monitoring cache cluster health
How to do it...
How it works...
There's more...
See also
8. Scaling AppFabric Hosting, Monitoring, and Persistence
Introduction
Creating an initial base configuration
Getting ready
How to do it...
How it works...
See also
Adding and removing servers from the farm
Getting ready
How to do it...
How it works...
There's more...
See also
Application deployment on the farm
Getting ready
How to do it...
How it works...
See also
Configuration and management on the farm
Getting ready
How to do it...
How it works...
See also
Automating deployment with scripts
Getting ready
How to do it...
How it works...
See also
9. Configuring Windows Server AppFabric Security
Introduction
Windows Server AppFabric security building blocks
Running caching services using Domain accounts
Getting ready
How to do it...
How it works...
There's more...
Setting up security for persistence stores
Getting ready
How to do it...
How it works...
There's more...
Securing Windows Server AppFabric's monitoring store
Getting ready
How to do it...
How it works...
There's more...
Securing the Event Collection service
Getting ready
How to do it...
How it works...
There's more...
Index

Microsoft Windows Server AppFabric Cookbook

Microsoft Windows Server AppFabric Cookbook

Copyright © 2012 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: July 2012

Production Reference: 1190712

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham B3 2PB, UK.

ISBN 978-1-84968-418-7

www.packtpub.com

Cover Image by Artie Ng ( <[email protected]> )

Credits

Authors

Hammad Rajjoub

Rick G. Garibay

Reviewers

Adnan Masood

Zubair Ahmed

Alvin Lau

Acquisition Editors

Sarah Cullington

Kerry George

Lead Technical Editor

Azharuddin Sheikh

Technical Editors

Joyslita D'Souza

Unnati Shah

Project Coordinator

Joel Goveya

Proofreader

Aaron Nash

Indexer

Hemangini Bari

Graphics

Valentine D'silva

Manu Joseph

Production Coordinator

Nilesh R. Mohite

Cover Work

Nilesh R. Mohite

Foreword

Have you ever set foot in the kitchen with a certain hunger and found that you had no clue as to how to make that dish? At such a time a cookbook is a wonderful thing. That's why I appreciate this concept of a cookbook for workflows and services. At Microsoft when we build products they are often chocked full of little known but wonderful capabilities and guys like Hammad and Rick are just the sort of chefs that have what it takes to make you successful with it. AppFabric brings some terrific capabilities to Windows Server and IIS with distributed caching and terrific hosting features for WCF Services and WCF Workflow Services at no additional cost, so using it is a no-brainer but maximizing it will take the kind of insight you will find in this book. So break out the mixing bowls, spatulas, and turn on the oven... I can almost smell success from here.

Ron Jacobs

Senior Program Manager, Microsoft Corporation

About the Authors

Hammad Rajjoub works as an Architect Evangelist with Microsoft. Before joining Microsoft, he was awarded Microsoft's Most Valuable Professional award, seven years in a row. Along with being an MVP he was also a Microsoft Business Platform Technology Advisor. Being an MVP in Connected Systems gave him early access to Windows Communication Foundation, Windows Workflow Foundation, as well as Windows Server AppFabric. In his previous roles he has been a CTO at a technology startup, Vice President at one of the largest financial institutions, as well as a Solutions Architect at a leading consulting company.

He has over a decade of experience using Microsoft Technologies, especially .NET since its beta 1 release. He is a published author and a frequent speaker at technology conferences (including TechEd and Cloud Computing Asia). He has founded a number of developer and architect communities over the years and remains a passionate speaker and contributor at local technical communities in Singapore. He is also an active member of the International Association of Software Architects (IASA) - Singapore Chapter. His areas of interest include Cloud Computing, Enterprise Architecture, Design Patterns, and Quantum Computation.

At home he is a busy husband and father of twin girls and a baby boy. For more details visit his website at http://www.hammadrajjoub.net or on twitter: @hammadrajjoub.

Alhamdulillah - This work would not have been possible without the help and support from my family. Special thanks to my mother Noor and my wife Iman for being supportive and giving me time and help to complete this book.

I would also like to express my gratitude to my friend and co-author of this book, Rick Garibay, for accepting my invitation to co-author this book and sharing his feedback throughout the lifecycle of this book. Also, special thanks to Adnan Masood, Zubair Ahmed, and Alvin Lau for technically reviewing the book, providing feedback, and correcting numerous mistakes.

Last but not the least, thanks to the editorial and project team at Packt Publishing for giving me the opportunity to write this book, and also being patient and understanding through the process of writes, re-writes, technical edits, as well as cases of missed deadlines.

Rick G. Garibay is a developer, architect, speaker, and author on distributed technologies and is the General Manager of the national Connected Systems Practice at Neudesic. With over 13 years' experience delivering distributed solutions across industry sectors such as finance, transportation, hospitality, and gaming, he specializes in distributed technologies such as Microsoft .NET, Windows Communication Foundation, Workflow Foundation, and Windows Azure to help his clients deliver business value and drive revenue while reducing operational costs.

As a five-time Microsoft Connected Systems MVP, he is an active speaker, writer, and passionate community advocate and is the Co-Founder of the Phoenix Connected Systems User Group (pcsug.org), celebrating four years in operation. He serves as an advisor to Microsoft in a number of roles as a member of the Microsoft Application Platform Partner Advisory Council and long-time member of the Business Platform Advisors and Azure Technology Advisors groups.

Recent presentations include talks at the Microsoft SOA and Business Process Conference, Microsoft TechEd, Dev Connections, .NET Rocks, Desert Code Camp, and numerous Microsoft events and user groups throughout North America. He is a frequent contributor to industry publications such as CODE Magazine and maintains a blog at http://rickgaribay.net. You can catch up with Rick on Twitter @rickggaribay.

I would like to thank my loving, patient, and amazing wife Christie for being my rock and providing a foundation which has allowed us to grow a beautiful family while enduring the sometimes overbearing demands of my career. I'm also grateful to my wonderful children, Sarah and Ricky for tolerating the many lost nights and weekends holed up in my home office working on this book.

I would also like to thank Mickey Williams, VP Technology Platform Group at Neudesic for his support in taking on this project along with his words of encouragement and (always timely) sense of humor along the way.

Last but not least, I would like to thank my friend and co-author, Hammad Rajjoub for inviting me to participate in this project and trusting me to help carry out his vision for this book. Hammad and I both share a labor of love as it applies to the Microsoft distributed technology stack affectionately (and somewhat nostalgically) known as "Connected Systems" and this book is both a reflection and an acknowledgment of the tremendous work the WCF, WF, and Dublin teams have done in putting these tremendous capabilities within reach of developers tasked with solving tough distributed challenges today.

About the Reviewers

Adnan Masood is a Software Engineer and Architect with zeal for solving interesting algorithmic, business, and technology problems. With special interest in scalable architectures, algorithm design, application security, and software development, he has over a decade of hands-on experience in financial services and application service providers. He currently works as a System Architect for Green Dot Corporation, a leading pre-paid financial institution where he develops robust, scalable, and secure SOA based middle-tier architectures, distributed systems, and web applications. He is a Microsoft Certified Trainer and holds various technical certifications including MCPD (Enterprise Developer), MCSD .NET, and SCJP-II. He is attributed and published in print media and on the Web; he also taught Windows Communication Foundation (WCF) courses at the University of California, San Diego.

He regularly presents at local code camps and user groups. He is actively involved in the .NET community as Co-founder and President of the of San Gabriel Valley .NET Developers group and recipient of the INETA Community Champion Award for contributions to the developer community in Southern California.

He holds a Master's degree in Computer Science and is currently pursuing a doctorate in Machine Learning; specifically interestingness measures in outliers using belief networks. He also holds systems architecture certification from MIT and SOA Migration, Adoption, and Reuse Technique certificate from SEI, Carnegie Melon University. He can be reached at <[email protected]>.

Alhamdullilah - Thanks to my family for their constant support during the process of editing this book. I would also like to thank Hammad for the opportunity and both Hammad and Rick for putting up with my feedback and tech edits. Last but not least, thank you Joel for your great project coordination skills.

Zubair Ahmed is an experienced software developer, blogger, and technical presenter. His interests include software architecture, improving code quality, and keeping an eye on the latest technologies. He works as a Software Consultant for Infusion Development in Dubai. When he is not working he likes to spend time in front of his large monitor at home writing some code, go for long drives with his wife, or socialize with friends.

His technical blog is at zubairahmed.net and his tweet handle is @zubairdotnet.

For technology updates, subscribe to his Facebook page at http://facebook.com/zubair.ahmed.public.

www.PacktPub.com

Support files, eBooks, discount offers and more

You might want to visit www.PacktPub.com for support files and downloads related to your book.

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.

http://PacktLib.PacktPub.com

Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books.

Why Subscribe?

Fully searchable across every book published by PacktCopy and paste, print and bookmark contentOn demand and accessible via web browser

Free Access for Packt account holders

If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.

Instant Updates on New Packt Books

Get notified! Find out when new books are published by following @PacktEnterprise on Twitter, or the Packt Enterprise Facebook page.

Preface

Windows Server AppFabric is an extension of the Application Server Role on the Windows Server Platform. In a nutshell, Windows Server AppFabric frees Windows Communication Foundation (WCF) and Windows Workflow Foundation (WF) Service developers from common infrastructure plumbing by providing a robust, secure, composable, and reliable platform which provides caching, hosting, and monitoring capabilities, including support for long running workflow services, all on the Windows Platform. As such, Windows Server AppFabric is an evolution of the Windows Server platform, providing essential building blocks for first-classing WCF (for code-based services) and WF (for declarative workflow services) that are built using the .NET Framework 4 and Visual Studio 2010.

As an extension to IIS and WAS, Windows Server AppFabric relies on IIS's proven capabilities for hosting and lifecycle management, adding additional useful capabilities for working with WCF and WF services. In addition, Windows Server AppFabric takes advantage of Windows Server's robust event tracing mechanism (also known as ETW). ETW provides optimized and high-performing kernel-level instrumentation which greatly minimizes impact on the performance of WCF and WF services hosted in IIS with Windows Server AppFabric.

Whether you are a developer who wants to avoid the same repetitive tasks when preparing your WCF and/or WF services for deployment, or an IT Pro who wants to avoid complex XML for configuring hosting and monitoring options for the services you manage, you will instantly benefit from Windows Server AppFabric. Best of all, Microsoft has made this key extension to the Windows Server Platform available free of charge.

Written by both a former MVP and now Architect Evangelist with Microsoft and a five-time Connected Systems Developer MVP, the authors of this book both worked very closely with Microsoft during the development of the product (then codenamed "Dublin") participating in Software Design Reviews and early incubation initiatives. Hammad and Rick have advised customers of all shapes and sizes and fielded these capabilities in countless projects across various verticals in the two years since its general availability.

This book is full of practical, step-by-step guidance including useful tips and techniques that will allow you to build scalable, reliable, and secure service-oriented applications on the Windows Server Platform with IIS and Windows Server AppFabric.

What this book covers

Chapter 1, Installing Windows Server AppFabric, covers setting up your development environment to use Windows Server AppFabric. You'll learn how to install hosting, persistence and monitoring capabilities, including provisioning repositories, choosing the appropriate storage options, making changes to configuration after installation, and troubleshooting common (and not so common) installation issues you might encounter along the way.

Chapter 2, Getting Started with AppFabric Caching, introduces Caching in Windows Server AppFabric, covering everything you need to get started with introducing this important capability to your composite applications and services. You will learn how to set up and use Caching using code and configuration options, as well as working with Caching within your applications. In addition, you'll learn how easily an existing application that relies on ASP.NET session state can immediately benefit from Windows Server AppFabric Cache, handling common error conditions, using PowerShell commandlets, and building a custom provider model.

Chapter 3, Windows Server AppFabric Caching — Advanced Use Cases, builds on the concepts in the previous chapter, covering the use of Regions and Tags as well as choosing the right concurrency mode and establishing expiration, eviction, and notification policies. You will also learn advanced monitoring concepts including the use of performance counters, configuring high availability, and common troubleshooting techniques for getting the most out of Windows Server AppFabric Cache.

Chapter 4, Windows Server AppFabric Hosting Fundamentals, introduces Windows Server AppFabric's hosting capabilities, covering common deployment, management, and hosting scenarios. You'll learn how to host WCF SOAP and REST services as well as simple WF services along with a number of tips and tricks for moving beyond the service template defaults.

Chapter 5, More Windows Server AppFabric Hosting Features, covers additional hosting topics, including supporting long-running WF services, how your services can benefit from the Auto-Start feature, properly hosting WCF services that take advantage of Windows Azure Service Bus Relay bindings for enabling modern, hybrid scenarios as well as common PowerShell commandlets for scripting many of the tasks covered in this and the previous chapter.

Chapter 6, Utilizing AppFabric Persistence, provides ample coverage of Windows Server AppFabric persistence capabilities, including configuring persistence for WF services, working with multiple persistence stores, and developing instance store, control, and query providers. This chapter also provides an in-depth walkthrough of development and configuration of custom instance, control, and query providers.

Chapter 7, Monitoring Windows Server AppFabric Deployment, provides an introduction to the monitoring capabilities provided by Windows Server AppFabric. Topics include collecting and viewing events from WCF and WF services, enabling tracing and configuring tracking profiles, and leveraging PowerShell cmdlets for monitoring WCF and WF services as well as the Caching service. In addition, you'll learn how to surface monitoring information to any user experience by following the sample recipe for building a custom monitoring dashboard using ASP.NET MVC and OData.

Chapter 8, Scaling AppFabric Hosting, Monitoring, and Persistence, covers a common scenario for scaling Windows Server AppFabric across multiple IIS hosts. You will learn how to prepare two hosts for clustering using Microsoft NLB as well as understand deployment, management, and administration of a multi-host Windows Server AppFabric deployment that shares a common, centralized persistence store.

Chapter 9, Configuring Windows Server AppFabric Security, covers what you need to know about planning and implementing a security model with Windows Server AppFabric. You will learn how to secure the caching, persistence, monitoring, and eventing (via ETW) subsystems of Windows Server AppFabric.

What you need for this book

This book assumes you have a solid foundation in messaging and workflow concepts and are proficient in developing web services with WCF 4.0 and WF 4.0, in addition to C#, the .NET Framework, and Visual Studio 2010. You will need a Windows 7 (or Windows Server 2008/R2) machine configured for IIS 7 along with SQL Server and Visual Studio 2010, as well as either Windows Server AppFabric or Microsoft AppFabric 1.1 for Windows Server.

To take advantage of the latest caching features introduced in AppFabric 1.1, it is recommended that you install Microsoft AppFabric 1.1. for Windows Server. Otherwise, Windows Server AppFabric (the first version of this release) will suffice and is the product name we use throughout this book.

Either version can be installed on Windows 7, Windows Server 2008, Windows Vista R2, or Windows Server 2008 R2 and they support both 32- and 64-bit architectures. You will also need Microsoft .NET Framework v4, IIS7, and Windows PowerShell 2.0. In terms of hardware, officially, any 1GHz+ CPU (900MHz+ for Dual Core and 700MHz+ for Quad Core) with 2 GB of RAM will be sufficient to get up and running. However, it is recommended that you have at least 4 GB of RAM to run Windows Server AppFabric or Microsoft AppFabric 1.1 for Windows Server.

Who this book is for

Whether you are an architect or developer designing and developing composite solutions with WCF and WF services or an IT Pro tasked with their deployment and maintenance; or designing and implementing a distributed caching strategy for your .NET services and applications, this book is for you.

This book does not assume any prior knowledge of Windows Server AppFabric; however, a basic understanding of .NET Framework 4.0, Windows Communication Foundation (WCF), and Windows Workflow Foundation (WF) technologies is required.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "Once the Caching service is up and running, we can query it for the caches that are available in this cluster by using the Get-Cache command."

A block of code is set as follows:

internal enum AckNack { Ack, Nack, Pending, }

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

<microsoft.applicationServer> <monitoring> <default enabled="true" connectionStringName="ConnectionString" monitoringLevel="Troubleshooting" /> </monitoring> </microsoft.applicationServer>

Any command-line input or output is written as follows:

Get-ASAppMonitoring -SiteName "Default Web Site" -VirtualPath /ReservationService

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "In IIS, click on the application and select Features View."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book — what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to <[email protected]>, and mention the book title through 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 on www.packtpub.com/authors.

Customer support

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.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. 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.

Errata

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 would 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/support, 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.

Piracy

Piracy of copyright 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.

Questions

You can contact us at <[email protected]> if you are having a problem with any aspect of the book, and we will do our best to address it.

Chapter 1. Installing Windows Server AppFabric

In this chapter, we will cover:

Installing Windows Server AppFabricConfiguring Windows Server AppFabric (hosting and monitoring)Configuring Windows Server AppFabric (caching)Installing caching Client AssembliesChanging the Windows Server AppFabric configuration after installationStarting a Caching serviceTroubleshooting Windows Server AppFabric configuration errorsTroubleshooting Windows Server AppFabric auto restart issues

Introduction

Windows Server AppFabric is an extension of the Application server role on the Microsoft Platform. Windows Server AppFabric offers in-memory, super-fast, scalable caching capabilities for web applications and services. For applications built using Windows Communication Foundation (WCF) and Workflow Foundation (WF), Windows Server AppFabric provides streamlined hosting and monitoring capabilities that support composition scenarios.

Windows Server AppFabric is built on top of an existing set of technologies on the Windows platform including, but not limited to Internet Information Services (IIS), Windows Process Activation Service (WAS), .NET Framework v 4.0, and Event Tracing for Windows (ETW).

In this chapter, we will look at how to set up Windows Server AppFabric using the different configuration options. We will also see how the configuration of Windows Server AppFabric can be changed after the installation. Lastly, at the end of the chapter, we will see how to troubleshoot some common problems with Windows Server AppFabric installations.

Installing Windows Server AppFabric

Windows Server AppFabric is an extension of the Application Server role on the Windows platform. At the time of this writing there are two ways to install Windows Server AppFabric. One is the standard direct install and the other is using Microsoft's new and exciting Web Platform Installer (WPI).

In this recipe, we will go through the step-by-step instructions to install Windows Server AppFabric using WPI. Needless to say, if you already have Windows Server AppFabric installed on your machine, then you can skip this recipe.

Note

WPI is the preferred approach because it streamlines the installation process by smartly identifying and installing the prerequisite software.

Getting ready

Windows Server AppFabric can be installed on Windows 7, Windows Server 2008 SP 2, Windows Vista R2, and Windows Server 2008 R2 (it supports both 32 and 64 bit architectures). You will also need Microsoft .NET Framework v4, IIS7, and Windows PowerShell 2.0. In terms of hardware, officially, any 1GHz+ CPU (900MHz+ for Dual Core and 700MHz+ for Quad Core) with 2 GB of RAM will be sufficient to get up and running with Windows Server AppFabric. However, it is recommended that you have at least 4 GB of RAM to run Windows Server AppFabric.

Note

If you want to try Windows Server AppFabric before actually installing it on your host machine, it makes sense to use a virtual machine that has Windows Server AppFabric installed on it so that you can play with it. The good news is that Microsoft has made a preconfigured Windows Server AppFabric VM available on MSDN that can be downloaded and used with Microsoft's Virtual PC. This download is available as a part of Microsoft's training kit for Windows Server AppFabric. The download is available at: http://www.microsoft.com/download/en/details.aspx?id=7956.

How to do it...

WPI offers a highly streamlined package/software download installation mechanism. You can get WPI from Microsoft's website at: http://www.microsoft.com/web/downloads/platform.aspx. After downloading and installing WPI, you can use the following steps to launch Windows Server AppFabric Installer:

Under the Start menu, go to All Programs. If you are using Windows 7, type Web Platform Installer in the custom menu item, find the WPI as shown in the following screenshot, and launch it:Accept the User Account Control (UAC) warning. This will allow WPI to make changes to your computer.Click on Next at the bottom of the screen to get started with the WPI.Type AppFabric in the search box (in the top right-hand corner of the screen) and press the Enter key:This will reveal a search result showing Windows Server AppFabric. Click on Add and then on Install to continue:Now, WPI will ask to review the download and install of all the required software components to run Windows Server AppFabric. Select I Accept to continue.

Note

The list of components, third-party application software, and Microsoft products will vary from machine to machine. WPI will determine the missing software and will list it on this screen.

Once you select I Accept, WPI will download and install all the required software components one by one. Sometimes this may result in multiple reboots for the host machine.Once all the required software components are installed, the Windows Server AppFabric installation will be complete. Click on Finish:

How it works...

The Windows Server AppFabric installation adds three new Windows services: AppFabric Caching Service, AppFabric Event Collection Service, and AppFabric Workflow Management Service, for caching, monitoring, and hosting scenarios respectively. These services can be seen when the Services Snap-in is launched from the Control Panel (or by typing Services.msc in the search box under the Windows Start menu).

As we can see in the preceding screenshot, only AppFabric Event Collection Service and AppFabric Workflow Management Service have Status as Started and have Startup Type defined as Automatic. By default, Windows Server AppFabric Caching Service is not available for use after a machine reboot.

Note

AppFabric Event Collection Service, AppFabric Workflow Management Service, and Windows Server AppFabric Caching Service form the heart of Windows Server AppFabric. These services work in the background and perform tasks such as collecting events, managing the workflow's life cycle, connecting to the cache cluster, and serving cache related requests.

Once Windows Server AppFabric is installed, the next step is to configure it using the Windows Server AppFabric Configuration wizard.

Configuring Windows Server AppFabric (hosting and monitoring)

There are a number of configuration options available when configuring Windows Server AppFabric, and in this recipe we will go through them. At this point, we should appreciate Microsoft's efforts in designing Windows Server AppFabric, as it allows a fair bit of customization.

Getting ready

Configuring Windows Server AppFabric is available via the Windows Server AppFabric Configuration wizard. It is a fairly simple task, but it requires careful consideration of a number of options and possibilities. We will need the following items ready in order to configure Windows Server AppFabric:

Service accounts to run (with administrative privileges)
AppFabric Hosting's Event Collection serviceAppFabric Hosting's Persistence service
SQL server database for:
(SQL server based) monitoring provider(SQL server based) persistence providerAppFabric caching store service provider (if your machine is part of a domain)
UNC file share for Windows Server AppFabric Caching service configuration provider (if the host machine is running in a workstation mode)Information on cluster set up (for a high-availability scenario)

Note

When HA (High Availability) is enabled Windows Server AppFabric Cache stores a copy of each cached object or region in a separate cache host. HA is discussed in detail in Chapter 7, Monitoring Windows Server AppFabric Deployment.

Unique port numbers for cache, cluster, arbitration, and replication

Note

It should be noted that when you run the Windows Server AppFabric Configuration wizard and make changes to the configuration, it will overwrite any existing values.

How to do it...

To launch the Window Servers AppFabric Configuration wizard, go to All programs under the Start menu, find AppFabric, and then select Configure AppFabric.

The following is a sequence of steps that will take you through the configuration wizard for Windows Server AppFabric:

Run the Configure AppFabric wizard.Accept the User Account Control (UAC) dialog, confirming that you will allow this program to make changes to your host machine:Click on Next at the bottom of the screen to start the configuration of Windows Server AppFabric.Once you are at the Configure Hosting Services screen, select the box titled Set monitoring configuration:Select the service account required to run the AppFabric Event Collection service by clicking on Change.If you do not have a ready-made account available for the event collection service, then you can leave the default value of NT Authority\Local Service, (as this can be modified later on). For more details on security, please refer to the How it works... section, as well as Chapter 9, Configuring Windows Server AppFabric Security.Now select the Monitoring provider, as this will provide access to the monitoring database. (As there is only one default SQL-based implementation, select the System.Data.SqlClient option.)

Note

Windows Server AppFabric by design allows adding multiple providers for monitoring and persistence. Configuring multiple persistence providers is discussed in Chapter 5, More Windows Server AppFabric Hosting Features.

Now click on Configure to launch the SQL configuration screen to help you select/configure the SQL server instance that will be used to store monitoring information.Select Register AppFabric monitoring store in root web.config.Select Initialize monitoring store.Under Connection String, provide the SQL Server name, for example,<HostServerName>\<SQLInstanceName>.Provide the Database name for the SQL Server.

Note

The SQL database (specified above in steps 11 and 12) is used to store Windows Server AppFabric monitoring related information. The Initialize monitoring store option will initialize the database with the monitoring schema.

The first half of your configuration screen should appear as follows:Now we will set up the Security Configuration to access the SQL Server database instance that we selected/created previously. For Windows authentication, if you have selected a complete install, then you will see default values for Administrators, Readers, and Writers in Security Configuration. If you already have roles defined and you have opted to initialize the Monitoring Database, then you can browse and select the appropriate roles. Otherwise, use the default values of AS_Administrators and AS_Observers as Administrators/Writers and Readers respectively. This is shown in the following screenshot:

Note

Windows Server AppFabric's AS_Administrators is a conceptual and administrative role. As the name implies it allows full control over AppFabric's configuration, monitoring, and persistence capabilities. Event Collection and Workflow Persistence services run under this role.

Likewise, AS_Observer is also a conceptual and administrative role. It allows you to view the application and services configuration, monitor data, as well as view persisted instances, all without being able to modify anything.

However, if you wish to choose SQL Server Authentication, you will need to provide a username and password that will be used to connect to SQL Server database. In this recipe we will only use Windows authentication.Once you click on OK you should see a confirmation dialog asking you to validate whether you want these settings to take effect:Click on Yes, and the wizard will go ahead and create and initialize the monitoring store. Once completed, you should see a validation dialog advising you that the Monitoring store was initialized and registered successfully:On the Configure Hosting Services screen, select Set persistence configuration.Now, select an AppFabric Workflow Management service account. Just like the service account for monitoring, we will need a service account that has admin rights and can access the persistence provider/store. If you have an account already available for this then click on Change and select it. Otherwise, use the default value of the NT AUTHORITY\LOCAL SERVICE account:From the Persistence provider dropdown, select a sqlStoreProvider and then click on Configure. Now this screen should look familiar, as it is the same one we used to set up Windows Server AppFabric Monitoring earlier on. We will once again select Register AppFabric persistence store in root web.config. We will also select Initialize persistence store and provide the SQL Server and Database names:Just like we set up the Security Configuration for the Windows Server AppFabric Monitoring database, repeat the same steps and use built-in accounts for the persistence database.Click on OK and proceed to confirm the changes. This will complete the configuration of the Hosting and Monitoring parts of Windows Server AppFabric.

How it works...

The configuration of Windows Server AppFabric provides contextual information to run Windows Server AppFabric services that are responsible for monitoring and hosting services. The values that we configured can be changed later, either by running the AppFabric Configuration wizard again or by using Windows Server AppFabric PowerShell commandlets (Cmdlets).

Note

Windows PowerShell is built on top of Microsoft.NET and offers a task based command-line shell and scripting language. Windows PowerShell has built in commands called Cmdlets (pronounced as commandlets). Cmdlets are lightweight commands and typically return a Microsoft.NET Framework object type to the next command in the pipeline.

It should be noted that monitoring and persistence services should be run under accounts with administrative privileges so that they can read and persist events to the preconfigured monitoring and persistence databases.

Configuring Windows Server AppFabric (caching)

Once you have finished configuring the Hosting Services as discussed in the preceding recipe, the next task is to configure the Caching Services for AppFabric. Just like in the preceding recipe, we will select a service account that should be part of the administrator group so that it has an administrative access to the caching configuration provider. Once again we will consider a workstation configuration and select a valid local system account.

We will see how to setup the Caching Configuration Store Provider. At the end of this recipe, we will also see how to join/create a new cache cluster (that this, the instance of Window Server AppFabric Cache is part of) along with the end point details (that is, port addresses) used by AppFabric services to communicate on the network.

Once we have configured Windows Server AppFabric Caching Services, we will be able to start using AppFabric Caching.

Getting ready

To begin this recipe, we will need the following in place:

A service account for the AppFabric Caching service.A file share (UNC Server Share) to store XML based cache configurations or a SQL Server database for a SQL Server based AppFabric Configuration store. (This is required for configuring a High Availability Caching Service scenario that runs on Windows Server 2008.)

How to do it...

To set up Windows Server AppFabric Caching follow these steps:

Run the AppFabric Configuration wizard.Accept the User Account Control (UAC) dialog, confirming that you will allow this program to make changes to your computer.Click on Next on the Before you Begin and Configure Hosting Services screens to reach Configure Caching Service.

Note

You cannot directly select Caching Service Configuration from the left-hand navigation panel on the Windows Server AppFabric Configuration Wizard.

Once you are on the Caching Service screen of the Configure AppFabric wizard, select the Set Caching Service configuration.Under Caching Service Account, click on Change. This will allow you to select the identity for the Caching Service Account.If your machine is in workstation mode, then you cannot change the service account. Otherwise, you can browse and select a local account (that has administrative access to the Caching Configuration store).Select XML from the Caching Service configuration provider dropdown.The SQL Server based configuration is not available for the Caching Configuration Service in workstation mode. If you select SQL provider and click on Configure, you will get the following error message:

Note

We discuss the use of SQL Server AppFabric Caching Service Configuration Store Provider in more detail in Chapter 7, Monitoring Windows Server AppFabric Deployment.

Under File Share, provide a file path of an existing UNC file share. This will allow Windows Server AppFabric's Configuration Service to store and manage information stored as an XML file under this provided path. Your screen will appear as follows:It should be noted that the File share (UNC server share) selection wizard will not allow you to create a new file share. As highlighted in the beginning of the recipe, it is required to have a UNC file share readily available. Under cluster information select New Cluster and click on Next.Configure AppFabric Cache Node by providing a unique port number value (numbers must be between 1024 and 65535) for the Cache port, Cluster port, Arbitration port, and Replication port.

Note

The Cache port is used for transmitting data between Cache Clients and Cache Hosts. The Cluster port enables Cache Cluster formation and Management. The Arbitration port is used to double check if the Cache Host is unavailable. Arbitration is used when the Cache Host fails. The Replication Host is used to move data between the Cache Hosts. Replication is used when Cache is configured for High Availability.

Configure Windows firewall exceptions by selecting the rules for Windows Server AppFabric Caching Service and Remote Service Management. Your screen should appear similar to the following:

Note

If you are using any third-party (non-Microsoft) firewall then you will need to manually update the firewall rules. This must be done to allow Windows Server AppFabric to use the ports that were specified during its configuration.

After clicking on Next, click on Yes on the Windows Server AppFabric Configuration Wizard dialog box and you will come to the end of the wizard with an option to launch IIS to further manage Windows Server AppFabric. Click on Finish to close the wizard.Congratulations! You have fully configured Windows Server AppFabric. Click on Finish.

Note

The High Availability feature of Windows Server AppFabric Caching can only be enabled on Enterprise versions of Windows Server 2008/2008 R2. This implies that all the nodes in the cluster must have enterprise editions of Windows Server 2008/2008 R2. For more information you may refer to: http://go.microsoft.com/fwlink/?LinkId=164929.

How it works...

The Windows Server AppFabric Caching Service requires a service account to run its Windows service as well as a configuration provider where it can store its configuration. As the caching service runs under the identity of the provided account, the account must have administrative privileges so that it can access and modify the configuration.

The Windows Server AppFabric Caching Service needs to identify which ports to connect to in order to communicate with the other hosts in the cluster. Once the port numbers are specified, ensure that any software or hardware firewalls are not blocking these ports.

As we experienced in this recipe, the Windows Server AppFabric Caching Service is highly configurable and the configuration wizard makes it extremely easy to set up (or change) the existing configuration.

Now that we have configured Services for AppFabric and all the services are up and running under valid service accounts along with firewall rule definitions, we can now start coding to test and start consuming the caching service.