A GUIDE FOR DEVELOPERS - Info.microsoft

Transcription

Understanding AzureA GUIDE FOR DEVELOPERS

AbstractThere is no time better to be a developer. With the cloud,you can compose solutions that were never possiblebefore. You can release new features to millions of users withinminutes. You can push the boundaries of current technologicallimitations in days. Developers can turn ideas from the groundup to successful businesses in only months. Companies needapps that allow them to maximize customer engagement anddifferentiate against competitors. Teams must have agility withapp development for faster time to market. Developers needa flexible platform to scale up and down based on businessdemands, yet rock-solid resources that can withstand failure.Microsoft Azure offers a cloud platform designed for developersto build the most innovative apps.This guide breaks down the “why” and “how” for scenariossuited to the cloud with a focus on building apps using platformservices available in Microsoft Azure. The second half of theguide showcases the breadth and depth of the Azure platformand services designed to help developers make truly competitiveand differentiated applications.The intended audience for this guide includes: Developers wanting to understand why Azure is the bestcloud platform for creating applications and how to getstarted quickly based on the app you want to build today. Technical leaders considering Azure to support new orexisting application development.PUBLISHED BYMicrosoft CorporationOne Microsoft WayRedmond, Washington 98052-6399Copyright 2016 by Microsoft CorporationAll rights reserved.This document is provided “as-is.” Information and views expressed in thisdocument, including URL and other Internet Web site references, may changewithout notice. You bear the risk of using it.Some examples are for illustration only and are fictitious. No real association isintended or inferred.This document does not provide you with any legal rights to any intellectualproperty in any Microsoft product. You may copy and use this document for yourinternal, reference purposes.2

Table of ContentsAbstract. 2Table of Contents . 3Overview.Introduction.The Changing World of App Development.Azure—the Cloud Platform Designed for You, the Developer.Summary .44458Common Cloud App Scenarios. 9Scenario 1: Building a Web App. 9Scenario 2: Building a Mobile App Back end. 16Scenario 3: Building an Internet of Things (IoT) App.20Scenario 4: Building a Custom Microservice-based App.23The Azure Platform Services.25App Service.25Azure Service Fabric.26Cloud Services. 27Azure Functions. 27Building on IaaS.29Docker and Containers .30Adding Superpowers to your Apps. 31Database Services.32Developer Services.33Identity.34Advanced Analytics & IoT.35Integration. 37Media Services & CDN.38Conclusion.39Recommended next steps.393

OverviewIntroductionThe cloud is changing expectations. Your customers expectmore. Your business expects more. You expect more.Companies you already know, such as Uber and Facebook,were born in the cloud, and almost every industry sector isadopting the cloud to drive business growth. These companiesmove faster, deliver more value, and meet our ever-changingneeds more effectively than those constrained by moretraditional approaches. They find new ways to use the flexibilityof the cloud to their advantage. They design ways to almostinfinitely scale out and gain deeper insights into their customersthat other companies can only dream about.Now you want to move to the cloud, too. And you’rewondering how to go about it. You want the benefits, butwhere do you start and how do you avoid the pitfalls thatcloud pioneers faced?British computer scientist David Wheeler famously said, “Allproblems in computer science can be solved by another layerof indirection.” And indeed, once companies figured out howto massively scale while controlling costs, it was just a matterof time before that layer would come to cloud computing.That layer is the application platform—and it’s here today.You can still control the maintenance, scaling, and redundancyof your application across a farm of commodity servers thatexpands and contracts to suit your needs. But now you candeploy on a platform that handles all that for you. This is the“second wave” of cloud computing— where you focus ondelivering the innovation your customers demand, not theinfrastructure required to run it.This guide is an introduction to the Azure application platform.It will provide the guidance and direction you need to startbuilding new applications or moving your existing applicationsto the cloud.The Changing World of AppDevelopmentIn the beginning, there were physical machines. They wereexpensive and developers loaded them up with multipleapplications to save costs. This caused no end of conflictsand unexpected bugs, yet effective machine utilization wasstill low. Developers struggled to make sure changes to oneapplication didn’t break an unrelated application.Then came virtual machines. Since multiple virtual machinescould be run on a single physical box, developers installedtheir applications in contained virtual machines, whichreduced conflicts and improved utilization, but welcome to4

OverviewUberRental CarOwn yourown carshared memory and unpredictable performance. And sinceprovision had to be made for the largest loads, “scaling in”focusing on building next gen products and services forthe cloud. Our services need to be always on, scale towouldn’t really save money.millions of users, and update seamlessly with newcapabilities. Just like our customers, we need an applicationplatform to work hard for us. We designed Azure toaccelerate developer productivity.Enter the cloud. Suddenly, companies could rent the virtualmachines they needed, when they needed them. They couldscale applications up and down on demand. You still neededto install and configure OS level patches and updates, andyou still had to contend with low-level networking. Still,hundreds of companies adopted infrastructure as a service(IaaS) and successfully leveraged the flexibility todramatically improve speed to market and scalability whilecontrolling costs. But most of the benefits of this modelaccrued to operations and infrastructure, not appdevelopment. As more companies realize that appinnovation needs to move faster than ever because ofcustomer and competitive demand, focus is shifting fromtraditional infrastructure cost savings to how to make appdevelopment more productive.So what differentiates a developer platform from aninfrastructure platform?It’s pretty simple, there are tiers of responsibility with benefitsand tradeoffs between them. For example, to use a car analogy,if you own a car you have to go through the purchase process,buy insurance, maintain and service it over a long period oftime, and provide parking or garaging.If you’re renting a car, you get the benefit of a car at yourdisposal for a fixed time period without any of the overheadof ownership. And, of course, an Uber or a taxi is likely to bethe most affordable option, but can have limits on flexibility—Azure—the Cloud PlatformDesigned for You, the DeveloperThe history of Microsoft is a history of developers. No othercloud provider is as steeped in development and developersas Microsoft. A BASIC interpreter was the very first Microsoftproduct back in 1975, and we have relentlessly focused onthe needs of developers since. We don’t just build theworld’s best platforms and developer tools, we use themourselves to build software and services for our customers.And we didn’t just build the world’s most developer-friendlycloud, we use it ourselves. We are a cloud-first company,Alaska Airlines needed to make an internal web appto book standby travel available to mobile employeesoutside of the corporate firewall. Developers took theexisting logic and moved the application to Azure AppService, created a mobile front end with Xamarin, andmade the app available to employees in record time.More about Alaska and Azure5

Overviewyou might have to wait five minutes, or maybe stand out inthe rain waiting for a ride.built-in staging, roll-back, testing-in-production, andperformance testing capabilities. You can monitor all aspectsYou can get more from your scarce developer time by usingan application platform that removes complexity andmaintenance responsibility. There might be some tradeoffconsiderations around flexibility, but overall, you can getmore done faster and with lower total cost of ownershipbuilding on platform as a service (PaaS).of your apps in real time and historically with detailed operationallogs. App Service handles the underlying infrastructure, removingthe need for you to maintain and patch your infrastructure.(There are still some situations where it makes sense to buildapps on IaaS that we’ll discuss later.)Let’s get down to the details with a short tour through the mainAzure platform services, explain where and when you mightuse them, then we’ll guide you through some common customerapp scenarios that will help you make the best design decisions.App Service—Web and Mobile AppsAzure App Service is a set of services thathas everything you need to build apps thattarget both web and mobile clients from asingle app back end. Supporting a range oflanguage options—.NET, Node.js, Java, PHP,and Python—it consists of Web Apps, Mobile Apps, Logic Apps,and API Apps. Web Apps and Mobile Apps provide back-endservices for web and mobile applications. API Apps allow youexpose APIs that can be securely consumed by any applicationand connect your app to dozens of popular services, like Office365 and Salesforce.com. And Logic Apps let you automatebusiness processes and coordinate workflows using tools rangingfrom a no-code experience to the full power of Visual Studio.Fully integrated DevOps allow you to deploy app updates withWhen to use itApp Service is the preferred option for building web or mobileback ends because it provides the productivity, scale,performance, and deployment options for most requirements.Use App Service when you want to focus on building uniquefeatures for your app and need the infrastructure to justwork. Additionally, it’s great for building an API layer whichcan be exposed to customers, partners and employeessecurely using the related API Management service. You canuse App Service in conjunction with the many other Azureservices (Redis Cache or Azure Traffic Manager, for instance)to quickly build and deploy powerful apps.Jet.com needed to innovate extremely rapidly to buildan effective e-commerce platform. Starting from ablank canvas they could choose any platform, andthanks to Microsoft Azure and its rich applicationplatform services, the company was able to release in12 months instead of two years.More about Jet.com and Azure6

OverviewService Fabric—Microservice Based AppsAzure Service Fabric is a platform thatdevelopers and ISVs can use to build andmanage custom microservice-basedapplications at cloud scale and with 24x7availability. Microservices are anarchitectural approach based on fine-grained, loosely coupledservices that can enable advanced developer agility, cloudscale, self-healing resilience and always on availability. ServiceFabric is the foundation for many Microsoft services such asAzure SQL Database, Azure Document DB, Cortana, WindowsIntune, and Skype for Business. We’ve taken the exact sametechnology and made it available to you. And use ServiceFabric wherever you want to run your microservice basedapps—whether in Azure, in your own datacenter or in otherclouds—giving you maximum flexibility.When to use itThe primary Service Fabric scenario is for building highlyscalable, always on services that can be updated with zerodowntime (like the Microsoft first party services mentionedpreviously). Use Service Fabric when you are creating a newapp or re-writing an existing app to leverage microservices,have committed to a cloud-first architecture, and requirerolling version updates with no downtime, distributedscalability and high performance, and low-latency data readand write.Cloud Services – Monolithic AppsAzure Cloud Services was the originalMicrosoft platform as a service (PaaS)service launched in 2010. Inspired by theneeds of developers, Cloud Servicesenabled them to easily deploy .NETapplications, taking advantage of cloud infrastructure likeVirtual Machines and Virtual Networks without having tomanage the low-level details and configuration of WindowsServer and the underlying infrastructure.When to use itCloud Services is an effective solution when you needdirect access to the underlying infrastructure or need toconfigure Internet Information Services (IIS) directly. LikeApp Service, you don’t need to deal with patching orupdating the underlying OS. Cloud Services is sometimesused to migrate existing web apps with dependencies onIIS configurations or required third party components—itprovides autoscaling while still allowing for many developerfocused platform benefits. Since Cloud Services wasintroduced, design options have evolved significantly. AppService and Service Fabric reflect a more modern approachto PaaS that you should consider as the foundation foryour application development.Azure Functions—Event Driven ExecutionAzure Functions provides serverless,compute for event-driven solutions thatextends the existing Azure applicationplatform with capabilities to implementcode triggered by events occurring in otherAzure services, SaaS products (like Office365 and Salesforce.com), and on-premises systems. With Functions, you only paywhile your function is actually executing. It provides an intuitive,browser-based user interface allowing you to create scheduledor triggered pieces of code implemented in a variety ofprogramming languages.When to use itWhen you want to create independent, unattended functionsthat respond to events across Azure, SaaS products and youron-premises services. Use them to add housekeeping orvalue-add features to your application without directlyrequiring a modification of your codebase. For instance, ifyour family-friendly site allows people to post their ownphotos, you could add an Azure Function that listens to thestorage area for new photos and uses some of the advancedAzure APIs to identify images that contain inappropriate7

OverviewContainersContainers are top of mind for developers, enablingyou to run your apps anywhere with agility andefficiency. Microsoft is working closely with partnerslike Docker and Mesosphere to offer solutions inthis space. Containers are often use in the IaaS layerbut are also popular for implementing microservicesbased solutions like Service Fabric. Read more aboutDocker and Containers and Azure Container Servicein this guide.once, run anywhere has been an industry mantra forever, butwith Azure you have unparalleled options through productslike Azure Stack that allow you to run your code in more places,unchanged. You bring the tools you love and skills you alreadyhave, and run virtually any application, using your data source,with your operating system, on your device.The modern developer is a solution composer, combiningcustom code with the best of finished services to create appsthat were unimaginable not so long ago. And delivering thoseapplications at amazing speed. Companies around the worldare using Azure to build new apps and extend existing appsto support and transform their business. How can you be next?content to replace the photo with a redacted version. Allthis can be achieved with no code changes at all to yourexisting application—it can be deployed completelyindependently with no impact on the existing application.SummaryAs a developer, you’re always curious about new technology.You want to experiment with new and interesting ideas tomake your apps better or create new apps. Previously, youhad to do much of the heavy lifting yourself—writing yourown capabilities or recreating a feature or service for everyapp you wrote.TalkTalk TV, the U.K.’s third largest cable TV provider,chose to redesign parts of their IaaS application to atake advantage of a microservices architecture withAzure Service Fabric. The new content managementand resolution platform allowed them to achieve fasterdelivery cycles and maintain uptime during upgradesMore about TalkTalk and AzureBut now you can implement modern solutions in a few linesof code. In addition to a rich application platform, Azure haspowerful services like machine learning, mobile engagementand analytics, and notifications ready for you to plug intoyour app and be on your way. You can always write your ownmobile notification service, but why not take advantage ofpre-built platform services and spend your time on thefeatures that make your app great?On Azure, you’ll find open source and cross-platform supportacross the broadest selection of programming languages,frameworks, tools, databases and architectures allowing youto realize the maximum reach for every line of code. Write8

Common CloudApp ScenariosYou’re ready to move to the cloud. You want the benefits,but are unsure where to start. The following scenarios aredesigned to give you a jumping-off point using commonapp workloads that many customers have.Note: Be sure to download the latest version of the AzureSDK. Check out this link to find all available downloads.Scenario 1: Building a Web AppBuilding a web app is maybe the most common app pattern.In this section we’ll look at how to migrate, scale, and securean existing web app.A. Building a Simple Web AppOverviewYou have an internal line-of-business application with a webfront end and a relational database back end. The applicationdoesn’t need to scale to millions of users, but is a criticalcomponent of your business. Currently, it’s accessed onlyinside the firewall, but you’d love it if people could reach intothe application from outside the LAN while still maintaininggood security principles.The problemHosting an application yourself imposes very real, butsomewhat hidden, costs. Some of these costs may includemanually deploying updates, patching operating systems,and using VPN connections required outside of the firewall.The cost is not overwhelming and is likely hidden in theoverall budgets and current assigned workloads. But thatdoesn’t make it any less real.The solutionFor this type of application, moving to Azure is relatively easy,and the benefits can be large. When on-premises, developersmay need to work with infrastructure teams whenever newversions of the application need to be rolled out to validatethat the application won’t interfere with other, potentially morecritical applications. In Azure, developers can deploy updatesearlier and more often using continuous deployment withon-premises and online version control systems like TFS,GitHub, BitBucket, and Visual Studio Team Services.Services Used Web AppsSQL DatabaseAzure Active Directory9

Common Cloud App ScenariosPatching operating systems is a necessary task. Poorlymanaged infrastructure can have serious securityconsequences or software implications. In Azure, the machinesthat sit under Azure Web Apps are automatically patchedand managed for you.Accessing company websites that require authenticationoutside of a firewall requires some form of a VPN connection.In Azure, integrating Azure Active Directory with your onpremises Active Directory can enable users to connect withtheir same credentials and even use multi-factor authenticationwithout the need for a VPN connection.The howInstinctively, you might consider shifting your virtual machinesinto Azure, setting up SQL Server, and configuring IIS. It maytake more time for you to configure everything just the wayyou want, but you have the control to do so. Your team willneed to be in charge of patching, maintenance, andadministration. This lift-and-shift model gives you the samefunctionality that you would expect from on-premisesdeployments. It may even be the fastest way to get to thecloud. But the cost and resource requirements are probablysimilar to your on-premises solution, just hosted in the cloud.Instead, you can bypass virtual machines and use an AzureWeb App in App Service to host your web app, Azure SQLDatabase for your database, and secure your web app byusing Azure Active Directory. This means you can takeadvantage of continuous deployment options to get up andrunning faster and maintain your app over time. Upload an SSL certificate and configure a custom domainname to the Web App. Deploy to the Web App repo continuously throughBitBucket, TFS, GitHub, or Mercurial.You can set up Azure Active Directory to sync with yourorganization’s on-premises Active Directory and connectusers to the web app through Windows authenticationoutside of the firewall. Download and install Azure AD Connect to integrate onpremises identities. Configure features of Azure AD Connect, such as filteringor password synchronization. Activate directory sync for Azure Active Directory in theportal. Enable authentication with Azure Active Directory for theWeb App and Azure SQL Database in the AzureManagement Portal.Storing data in the cloudAzure SQL Database is a managed relational SQL databaseas-a-service (DBaaS) solution in Azure – and distinct fromSQL Server running on Azure Virtual Machines. You don’thave to manage any virtual machines, operating systems,database software, or worry about upgrades, high availability,and backups. In general, Azure SQL Database can dramaticallyincrease the number of databases managed by a single ITor development resource. Deploy to SQL Database using SQL Server ManagementHosting a web app in the cloudWhether your app is written in .NET, Java, PHP, Node.js, orPython, you can deploy your web app to an Azure Web Appin App Service. You can manage multiple Web, Mobile, API,and Logic Apps in App Service. For most web applicationneeds, App Service is the answer. Deploy, copy, or migrate your web app to an AzureWeb App.Pro TipImplement staged deployment to swap stagingand production slots of your web apps with zerodowntime, and run A/B testing in production witha configurable fraction of your live traffic.10

Common Cloud App ScenariosStudio, export the database to a BACPAC file then importor use BCP, or use SQL Server transaction replication withminimal downtime.Additional resourcesDeploy your app to Azure App Service Once the database is up in Azure, connect to it the sameway you did on-premises through SQL ServerManagement Studio.Continuous delivery to Azure using Visual StudioTeam Services Copy the connection string and place it into the connectionstrings area for the Web App in Azure or other resourcesthat connect to it.Integrating your on-premises identities withAzure Active DirectorySQL Server database migration to SQL Database inthe cloudArchitecture diagramAzure Web AppAzure Active DirectoryAzure SQL Database11

Common Cloud App ScenariosB. Scaling a web appCreating a simple web app in Azure is easy enough, but anygrowing company wants to be able to scale and provideglobal reach for their web apps.The solutionTo scale your Azure Web App in App Service, you only needto slide a horizontal bar to increase the instance count ofthe web apps available. But you also want a consistentexperience for all users, whether your customer is at anInternet café in Rabat or in a hotel in Mexico City. Choosean Azure datacenter where your web app and database getdeployed, and Azure Traffic Manager will route users to theinstance of your app closest to their location. Geographicexpansion is a priority for Azure with support for new regionsbeing added over time.The howOne way to achieve scalability and availability is throughvirtual machines, load balancers and redundant resources.However, if you want your web app to always be available,you need to pay for the virtual machine and replicas to bealways available.In the same way that App Service removes the burden ofmanaging infrastructure it also makes it easier to scale out.Use an Azure Web App to host your web app, the databasein Azure SQL Database, and use Azure Traffic Manager toroute users to copies of the web app globally. Enable ActiveGeo-Replication in SQL Database for synchronizing replicasof databases. Use Azure Redis Cache to improve performanceby loading frequently accessed data and state information.Scaling and replicating an applicationAzure Web Apps allows you to scale the maximum numberof instances of your app up and down with a slider bar. Seta schedule for scaling up/down (such as during businesshours) or set a target CPU percentage and Azure will handlethe rest. Then quickly deploy the same code to Web Appsaround the world. Deploy, copy, or migrate your web app to an Azure WebApp in App Service. Set scheduled times for auto-scaling the web app up ordown or choose to scale by CPU load. Create at least one other Web App in another region. If pointing to another database, update the connectionstrings.Azure Web Apps already provides failover and round-robintraffic routing functionality for Web Apps within a datacenter.Traffic Manager allows you to specify failover and roundrobin traffic routing for Web Apps in different datacenters.Routing global users to a web appAzure Traffic Manager allows you to control the distributionof user traffic to your specified endpoints, such as Web Apps.The service applies an intelligent policy engine to DomainName System (DNS) queries for the domain names of yourInternet resources so that you can run your web apps indatacenters anywhere. Create a unique Traffic Manager profile and choose theload balancing method. In the Endpoints tab, add the Web App to point to. Set the monitoring settings for the Traffic Manager profileto ensure that the endpoints are available. You can specifythe protocol, the port, and the relative path.Services Used Web Apps SQL Database Traffic Manager Azure Redis Cache12

Common Cloud App Scenarios Point your company domain name to a Traffic Managerdomain name. Connect to the cache and store the credentials in theconnection strings area in the Web App.Storing data across the world Add and retrieve objects from the cache and specifyexpiration of items in the cache.Azure SQL Database is distinct from SQL Server in an AzureVirtual Machine because it provides Active Geo-Replication.Active Geo-Replication asynchronously replicates committedtransactions from a database to up to four copies of theprimary database on different servers. Use this feature for Enable cache diagnostics to monitor the health of the cache.Architecture diagramdisaster recovery or use an online secondary readabledatabase as a load balancer for read-only workloads servingclients distributed across several regions. Deploy your database to SQL Database using SQL ServerManagement Studio, export the database to a BACPACfile then import or use BCP, or use SQL Server transactionreplication with minimal downtime. Scale to the Premium service tier to choose the locationwhere the SQL Database is replicated. In Geo-Replication, add at least one secondary database,the target region, and target server.Boosting an application’s responsivenessAzure Redis Cache is based on the popular open-sourceRedis cache, an advanced key-value store that lets you operateon values (strings, hashes, lists, sets, and sorted sets) andhas master-subordinate replication and other performanceboosting features. This separate, distributed cache layerallows your data tier to scale independently for more efficientuse of compute resources in your application layer.Additional resourcesAbout Traffic Manager MonitoringActive Geo-Replication for Azure SQL DatabaseHow to use Azure Redis Cache Create the cache and configure the cache client.Pro TipLearn how the viral site “How-Old.NET” wascreated and scaled with Traffic Manager in thisAzure Friday session.13

Common Cloud App ScenariosC. Isolating a web appIsolating a web app in the cloudMany companies are

The primary Service Fabric scenario is for building highly scalable, always on services that can be updated with zero downtime (like the Microsoft first party services mentioned previously). Use Service Fabric when you are creating a new app or re-writing an existing app to leverage microservices,