Azure Service Management API A journey ending in billing, monitoring and usage
What are we going to learn?• How Visual Studio deploys under the covers• How to use tools and scripts to automate parts of the deployment• How to monitor asynchronous operations in a deployment• The fundamentals of how we interact Azure beneath all of the libraries and layers of abstraction• A small part of the Service Management API – there is much more SO does this interest me enough to work on a group Codeplex project?
What can I manage?• Hosted services• Storage accounts• Affinity groups• Security (X509v3 certificates)• Subscription history• Access Control Services
What tools can I use to manage?• The management portal!• Windows Azure Powershell CmdLets• The Azure MMC SnapIn• Visual Studio.NET• Third party tools such as those by Neudesic, Cerebrata, Paraleap and others• An RDP Client• Any device!
What do we mean by Management?• Create-Read-Update-Delete (CRUD)• Manage transaction security• Checking full audit history• Locations and “affinity groups”• Accessing and managing storage accounts• Track asynchronous long running operations• Get information about the host operating• Managing Access Control Services
Management API details• RESTful (REpresentational State Transfer)• Use of OData (ACS Management)• Use of HTTP and multiple verbs – GET, PUT, POST, DELETE• Endpoints are HTTPS protecting data in transit• Each request needs a “Management Certificate” attached for authentication purposes
Management Examples (CRUD)• Listing hosted services – GET http://management.core.windows.net/[subscription id]/services/hostedservices HTTP/1.1• Creating a hosted service – POST http://management.core.windows.net/[subscription id]/services/hostedservices HTTP/1.1• Deleting a hosted service – DELETE http://management.core.windows.net/[subscription id]/services/hostedservices/[SERVICE NAME] HTTP/1.1• Updating a hosted Service – PUT http://management.core.windows.net/[subscription id]/services/hostedservices/[SERVICE NAME] HTTP/1.1
What else goes into the request?• Header x-ms-version: 2011-10-01• Content-type: application/xml• X509v3 certificate• Either blank request OR• XML Document with well known schema
DEMOCreating and Deleting a Hosted Service Programmatically
My Request Message<?xml version="1.0" encoding="utf-8"?><CreateHostedServicexmlns="http://schemas.microsoft.com/windowsazure"> <ServiceName>lwaugtest1.bad</ServiceName> <Label>djE=</Label> <Description>this is the first test service for the user group</Description> <Location>North Europe</Location></CreateHostedService>
My Response ExceptionHTTP/1.1 400 Bad RequestContent-Length: 194Content-Type: application/xml; charset=utf-8Server: Microsoft-HTTPAPI/2.0x-ms-request-id: 3badf9cdddc540cd922993fa01598297Date: Mon, 05 Dec 2011 18:16:45 GMT<Error xmlns="http://schemas.microsoft.com/windowsazure"xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><Code>BadRequest</Code><Message>The hostedservice name is invalid.</Message></Error>
DEMOCreating and Deleting a Hosted Service with Powershell
Steps to Using Powershell CmdLets to Deploy• Generate a certificate with the following command: – makecert -r -pe -n "CN=Richards New Cert" -a sha1 -len 2048 -ss My "C:richard2.cer“• Add the certificate through the management portal• Open powershell after CmdLets are installed and enter: – Add-PSSnapin AzureManagementToolsSnapIn• Create new Blob container via Storage Services API• Upload .cspkg to Blob Storage• Enter the following into Powershell: – New-Deployment -serviceName lwaugtestone -subscriptionId edd1c493-f3f5-42d0-ba03- 7bf1eb2cfcaa -certificate (get-item cert:CurrentUserMY7A67E9C2225C4930CBFCEF869C993EB560A3B1A4) -slot production – package http://lwaugbe.blob.core.windows.net/packages/HelloCloud.cspkg -configuration "C:ProjectsTech ProjectsLondon Windows Azure User GroupHelloCloudHelloCloudbinReleaseapp.publishServiceConfiguration.Cloud.cscfg" - label lwaugtestone• Followed by: – Set-DeploymentStatus -subscriptionId edd1c493-f3f5-42d0-ba03-7bf1eb2cfcaa -certificate (get-item cert:CurrentUserMY7A67E9C2225C4930CBFCEF869C993EB560A3B1A4) - ServiceName lwaugtestone -Status Running -slot Production
Steps to Using Fiddler and Azure• Use Request Builder• Add certificate file to C:UsersxxxMy DocsFiddler2ClientCertificate.cer• Add the ms-version-x header• Request the following: – GET https://management.core.windows.net/edd1c493-f3f5- 42d0-ba03-7bf1eb2cfcaa/operations/[token] HTTP/1.1• Look for an InProgress or Succeeded response
Summary• Service Management is web friendly, open, platform independent and standardised• There are a variety of tools and APIs available to manage services• RESTful services mean you can manage from ANY client application• Ability to create complex continuous integration testing scenarios and deployments with staging and production environments• Ability to manage multiple subscriptions simultaneously• No real constraint on the activities that can be accomplished• All transactions are fully secure
http://azuresm.codeplex.com Azure Service Manager is an enterprise application which provides an subscriber-based API through WCF to allow clients to collect information on multiple Azure subscriptions, including hosted services, SQL Azure and storage services. It provides service, usage and billing data.