Before you install and use Window Azure ServiceManagement Sample you must:
- Review the Windows Azure ServiceManagement Sample license terms by clicking the Custom link above.
- Print and retain a copy of the license terms for your records.
By downloading and using the Windows Azure ServiceManagement Sample, you agree to such license terms. If you do not accept them, do not use the software.
Introduction
The Windows Azure ServiceManagement sample is a command-line tool that uses the Service Management API to perform various service management tasks, such as retrieving
information about a Windows Azure subscription, creating and deploying a hosted service, and updating a deployment.
Prerequisites
- Subscription identifier and certificate thumbprint
- You need the subscription identifier and the certificate thumbprint to perform operations on hosted services using the csmanage application.
- Windows Azure SDK
–
provides tools and files that are needed to complete the development process of an application for Windows Azure.
- Visual
Studio 2010 –
the sample provides a Visual Studio 2010 project that you can use to build the sample.
To
find the subscription ID and the certificate thumbprint
- Log
on to the Windows Azure Management Portal.
- Click
Hosted Services,
Storage Accounts & CDN, and then click
Management Certificates.
- In
the Properties pane, you can find the certificate thumbprint under
Thumbprint. The subscription identifier is under
Subscription ID.
Build and Run the Sample
To build and run the sample
- Open Visual Studio 2010 as an administrator.
- Browse to the csmanage folder where you extracted the sample and open csmanage.sln.
- Open the app.config file and locate the appSetting element. Add the SubscriptionId
and CertificateThumbprint key values, and then save the file.
- Press F6 to build the solution.
- Open a
Command Prompt window as an administrator, and then enter the csmanage command with the needed options. For more information about the available options, see the following section.
Csmanage
Options
Syntax
Windows Shell Script
Edit|Remove
windowsshell
csmanage /command [/resourcetype:resourcename] [optional-parameters]
csmanage /command [/resourcetype:resourcename] [optional-parameters]
Informational
Commands
Display
help information for the csmanage application.
Windows Shell Script
Edit|Remove
windowsshell
/?
List
the properties for the specified resource (hosted service/storage account/affinity group).
Windows Shell Script
Edit|Remove
windowsshell
/view-properties [/resourcetype:resource]
/view-properties [/resourcetype:resource]
Display
the status of the specified operation identifier. All API commands return an operation identifier in the x-ms-request-id header.
Windows Shell Script
Edit|Remove
windowsshell
/get-operation-status /op-id:<operation-id>
/get-operation-status /op-id:<operation-id>
Affinity
Group Commands
List
all affinity groups in the subscription. Use the view-properties option to display details on any particular affinity group.
Windows Shell Script
Edit|Remove
windowsshell
/list-affinity-groups
Storage
Account Commands
List
all of the storage services that are associated with the subscription.
Windows Shell Script
Edit|Remove
windowsshell
/list-storage-services
Display
the primary and secondary keys for the storage account. You must specify the storage account resource.
Windows Shell Script
Edit|Remove
windowsshell
/view-keys
Regenerate
storage keys by using the key-type parameter to specify the key to regenerate. You must specify the storage account resource.
Windows Shell Script
Edit|Remove
windowsshell
/regenerate-key /key-type:primary|secondary
/regenerate-key /key-type:primary|secondary
Hosted
Service Commands
Create
a hosted service.
Windows Shell Script
Edit|Remove
windowsshell
/create-hosted-service /hosted-service:<name> /label:<label> [/description:<description>] [/affinity-group:<affinitygroupname> /location:<locationconstraintname>]
/create-hosted-service /hosted-service:<name> /label:<label> [/description:<description>] [/affinity-group:<affinitygroupname> /location:<locationconstraintname>]
List
all of the hosted services that exist for the subscription. You can use the
/view-properties
informational
command to view details about a hosted service.
Windows Shell Script
Edit|Remove
windowsshell
/list-hosted-services
Update
a hosted service.
Windows Shell Script
Edit|Remove
windowsshell
/update-hosted-service /hosted-service:<name> [/label:<label>] [/description:<description>]
/update-hosted-service /hosted-service:<name> [/label:<label>] [/description:<description>]
Delete
a hosted service. You must specify the hosted service resource.
Windows Shell Script
Edit|Remove
windowsshell
/delete-hosted-service
Deployment
Commands
View
details about a specified deployment. You can specify the deployment either by deployment environment type or by name. You must specify the hosted service resource.
Windows Shell Script
Edit|Remove
windowsshell
/view-deployment /slot:staging|production
/view-deployment /slot:staging|production
Windows Shell Script
Edit|Remove
windowsshell
/view-deployment /name:<deployment-name>
/view-deployment /name:<deployment-name>
Create
a new deployment. The /package
parameter must contain the URI to a .cspkg file in blob storage that is associated with the subscription. The
/config
parameter must specify a .cscfg file on a local drive. You must specify the hosted service resource. If
/warnings-as-error
is specified, warnings are returned in ErrorDetails and the operation is terminated.
The
deployment name must be unique.
Windows Shell Script
Edit|Remove
windowsshell
/create-deployment /name:<name-of-deployment> /label:<label> /package:<blob-uri> /config:<filename> /slot:staging|production [/warnings-as-error]
/create-deployment /name:<name-of-deployment> /label:<label> /package:<blob-uri> /config:<filename> /slot:staging|production [/warnings-as-error]
Swap
the deployments in between the production environment and the staging environment. If the deployment exists in both the production and staging environments, you must specify the names of both deployments. If a deployment does not exist in the production environment,
the /production-slot parameter is not required. You must specify the hosted service resource.
Windows Shell Script
Edit|Remove
windowsshell
/swap-deployment /production-slot:<deployment-name-in-production> /source-deployment:<deployment-name-in-staging>
/swap-deployment /production-slot:<deployment-name-in-production> /source-deployment:<deployment-name-in-staging>
Delete
the specified deployment. You must specify the hosted service resource.
The deployment must be in suspended state to be deleted.
Windows Shell Script
Edit|Remove
windowsshell
/delete-deployment /name:<deployment-name>
/delete-deployment /name:<deployment-name>
Windows Shell Script
Edit|Remove
windowsshell
/delete-deployment /slot:production|staging
/delete-deployment /slot:production|staging
Change
the deployment status to ready or stopped. You must specify the hosted service resource.
Windows Shell Script
Edit|Remove
windowsshell
/update-deployment /status:running|suspended /name:<deployment-name>
/update-deployment /status:running|suspended /name:<deployment-name>
Windows Shell Script
Edit|Remove
windowsshell
/update-deployment /status:running|suspended /slot:production|staging
/update-deployment /status:running|suspended /slot:production|staging
Change
the configuration of the deployment. You must specify the hosted service resource.
Windows Shell Script
Edit|Remove
windowsshell
/change-deployment-config /config:<filename> /slot:production|staging [/warnings-as-error]
/change-deployment-config /config:<filename> /slot:production|staging [/warnings-as-error]
Windows Shell Script
Edit|Remove
windowsshell
/change-deployment-config /config:<filename> /name:<deployment-name> [/warnings-as-error]
/change-deployment-config /config:<filename> /name:<deployment-name> [/warnings-as-error]
Initiates
an in-place upgrade of the specified deployment. You must specify the hosted service resource.
Windows Shell Script
Edit|Remove
windowsshell
/upgrade-deployment /mode:auto|manual /label:<label> /config:<config-filename> /name:<deployment-name> [/warnings-as-error]
/upgrade-deployment /mode:auto|manual /label:<label> /config:<config-filename> /name:<deployment-name> [/warnings-as-error]
Windows Shell Script
Edit|Remove
windowsshell
/upgrade-deployment /mode:auto|manual /label:<label> /config:<config-filename> /slot:staging|production [/warnings-as-error]
/upgrade-deployment /mode:auto|manual /label:<label> /config:<config-filename> /slot:staging|production [/warnings-as-error]
Walk
the specified upgrade domain. You must specify the hosted service resource.
Windows Shell Script
Edit|Remove
windowsshell
/walk-upgrade-domain /domain:<update-domain-number> /slot:production|staging
/walk-upgrade-domain /domain:<update-domain-number> /slot:production|staging
Windows Shell Script
Edit|Remove
windowsshell
/walk-upgrade-domain /domain:<update-domain-number> /name:<deployment-name>
/walk-upgrade-domain /domain:<update-domain-number> /name:<deployment-name>
Request
the reboot of a single role instance in the deployment. You must specify the hosted service resource.
Windows Shell Script
Edit|Remove
windowsshell
/reboot-deploymentroleinstance /slot:<staging|production> /role-instance-name:<roleinstancename>
/reboot-deploymentroleinstance /slot:<staging|production> /role-instance-name:<roleinstancename>
Windows Shell Script
Edit|Remove
windowsshell
/reboot-deploymentroleinstance /name:<deploymentname> /role-instance-name:<roleinstancename>
/reboot-deploymentroleinstance /name:<deploymentname> /role-instance-name:<roleinstancename>
Request
the reimaging of a single role instance in the deployment. You must specify the hosted service resource.
Windows Shell Script
Edit|Remove
windowsshell
/reimage-deploymentroleinstance /slot:<staging|production> /role-instance-name:<roleinstancename>
/reimage-deploymentroleinstance /slot:<staging|production> /role-instance-name:<roleinstancename>
Windows Shell Script
Edit|Remove
windowsshell
/reimage-deploymentroleinstance /name:<deploymentname> /role-instance-name:<roleinstancename>
/reimage-deploymentroleinstance /name:<deploymentname> /role-instance-name:<roleinstancename>
Certificate
Commands
List
the certificate thumbprints for a hosted service. You must specify the hosted service resource.
Windows Shell Script
Edit|Remove
windowsshell
/list-certificates
Add
a certificate to the specified hosted service. You must specify the hosted service resource.
Windows Shell Script
Edit|Remove
windowsshell
/add-certificate /cert-file:<path-to-cert-file> /cert-format:[pfx] /cert-password:<password>
/add-certificate /cert-file:<path-to-cert-file> /cert-format:[pfx] /cert-password:<password>
Deletes
certificate with specified thumbprint and algorithm. Should have hosted service resource specified.
Windows Shell Script
Edit|Remove
windowsshell
/delete-certificate /cert-thumbprint:<thumbprint> /algorithm:<algorithm>
/delete-certificate /cert-thumbprint:<thumbprint> /algorithm:<algorithm>
Operating
System Commands
List
all of the operating systems that you can use to create a deployment in Windows Azure.
Windows Shell Script
Edit|Remove
windowsshell
/list-operating-systems
List
all of the operating system families and the operating systems that belong to them.
Windows Shell Script
Edit|Remove
windowsshell
/list-operating-system-families
/list-operating-system-families
Location
Commands
List
all of the locations that are accessible from a subscription.
Windows Shell Script
Edit|Remove
windowsshell
/list-locations
Resources
Specify
the storage account name.
Windows Shell Script
Edit|Remove
windowsshell
/storage-service:<storage-account-name>
/storage-service:<storage-account-name>
Specify
the hosted service name.
Windows Shell Script
Edit|Remove
windowsshell
/hosted-service:<hosted-service-name>
/hosted-service:<hosted-service-name>
Specify
the affinity group.
Windows Shell Script
Edit|Remove
windowsshell
/affinity-group:<affinity-group-name>
/affinity-group:<affinity-group-name>
Examples
Create
a new deployment in staging.
Windows Shell Script
Edit|Remove
windowsshell
csmanage.exe /create-deployment /slot:staging /hosted-service:MyHostedService /name:MyDeployment /label:MyLabel /config:./ServiceConfiguration.cscfg /package:http://myaccount.blob.core.windows.net/packages/MyApplication.cspkg
csmanage.exe /create-deployment /slot:staging /hosted-service:MyHostedService /name:MyDeployment /label:MyLabel /config:./ServiceConfiguration.cscfg /package:http:
Update
the deployment status to running.
Windows Shell Script
Edit|Remove
windowsshell
csmanage.exe /update-deployment /slot:staging /hosted-service:MyHostedService /status:running
csmanage.exe /update-deployment /slot:staging /hosted-service:MyHostedService /status:running
Swap
the deployments in the staging and production environments.
Windows Shell Script
Edit|Remove
windowsshell
csmanage.exe /swap-deployment /hosted-service:MyHostedService /source-deployment:MyStagingDeployment /production-slot:MyProductionDeployment
csmanage.exe /swap-deployment /hosted-service:MyHostedService /source-deployment:MyStagingDeployment /production-slot:MyProductionDeployment
Change
the configuration or number of instances.
The number of role instances is defined in the ServiceConfiguration.cscfg file.
Windows Shell Script
Edit|Remove
windowsshell
csmanage.exe /change-deployment-config /hosted-service:MyHostedService /slot:production /config:./ServiceConfiguration.cscfg
csmanage.exe /change-deployment-config /hosted-service:MyHostedService /slot:production /config:./ServiceConfiguration.cscfg