How to Package your Service
The CSPack Command-Line Tool packages your service to be deployed to the Windows Azure fabric. The cspack.exe
utility generates a service package file that you can upload to Windows
Azure using the Windows Azure Platform Management Portal. By default
the package is named .cspkg
, but you can specify a different name if you choose.
CSPack command-line example
The following command line example creates a package that can be deployed as a hosted service. It specifies the service definition file to use. Using the /role option it specifies the directory where the binaries for the role reside and the DLL where the entry point of the role is defined. Using the /out option it specifies the out location for the role binaries and the name of the package file.
How to Deploy a Service in Windows Azure
The Windows Azure SDK provides an environment and tools for developing services to be deployed to Windows Azure. You can use the Windows Azure compute emulator and storage emulator to debug your application and perform mixed-mode testing. Then use the CSPack Command-Line Tool to package the application for deployment to the Windows Azure staging or production environment.
The following figure shows the stages of service development and deployment.
1. Test your service locally with the Windows Azure compute and storage emulators
You can debug your service locally, without connecting to Windows Azure, by using the compute and storage emulators. The Windows Azure compute emulator simulates the Windows Azure fabric, letting you run and test your service locally to ensure that it writes adequate information to the log. After your service is deployed to the Windows Azure staging or production environment, logging messages and alerts is the only way to gather debugging information. You cannot attach a debugger to a service that is deployed in Windows Azure. For more information about using the compute emulator to debug your service.
The storage emulator service simulates the Windows Azure storage services, letting you run and debug code that calls into the storage services and, together with the compute emulator, helps you test your service in the local environment. Once your service is running in the local development environment, you can change your configuration files to connect to Windows Azure and test against the production storage services in mixed mode.
To learn more about how to configure storage access URIs to access storage resources in Windows Azure or the storage emulator,
When your service is connected to the Windows Azure production storage services it runs in mixed mode, meaning that the service executes in the compute emulator, but your data is hosted in Windows Azure. Once local testing is complete, using mixed mode lets you test your service in a staging environment.
After you debug your service in mixed mode, you are ready to package it for deployment to Windows Azure.
Once
debugging is complete, use the CSPack Command-Line Tool to package your
service for deployment to the Windows Azure staging or production
environment. The cspack.exe utility generates a service
package file that you can upload to Windows Azure by using the Windows
Azure Platform Management Portal. The default package name is .cspkg
, but you can specify a different name if you choose.
If you have installed the Windows Azure Tools for Microsoft Visual Studio, you can package and deploy your service from within Visual Studio. For more information, see How to Publish a Windows Azure Application using the Windows Azure tools.
After you package your service, you can use the Windows Azure Platform Management Portal to create a hosted service that you can deploy to the Windows Azure staging or production environment.
You will need to upload two files:
- The service package file that you created with the cspack.exe utility.
- The service configuration file, which provides configuration values for your service.
When you upload the service package and configuration file, you will be provided with an internal staging URL that you can use to test your service privately in the Windows Azure staging environment. When you are ready to put your service into production, swap the service from the staging URL to the production URL.
How to Create a Hosted Service
Once you have written your Windows Azure application, you must deploy it to a Windows Azure hosted service.
-
Log into the Windows Azure Platform Management Portal.
-
On the ribbon, click New Hosted Service. This will open the Create a New Hosted Service window.
-
On the Create a new Hosted Service window select a subscription to add the hosted service to from the Choose a Subscription dropdown.
-
In Enter a name for your service, type a name for this service. This will help you identify this particular service when you have deployed multiple services.
-
In Enter a URL for your service, type a subdomain name to create the URL at which your service will be available.
-
If you have created Affinity groups and you want to assign this service to a particular group, click the radio button next to the Affinity Group dropdown. Otherwise leave the default setting of No Affinity.
-
From Choose a region select the region
-
If you are not deploying a package to the service at this time, click Do not deploy, and then click OK.
If you are deploying a service at this time follow the procedure in the next section.
When you deploy a service you can choose to deploy to either the staging environment or the production environment. A service deployed to the staging environment is assigned a URL with the following format: {deploymentid}.cloudapp.net. A service deployed to the production environment is assigned a URL with the following format: {hostedservicename}.cloudapp.net. The staging environment is useful as a test bed for your service prior to going live with it. In addition, when you are ready to go live, it is faster to swap VIPS to move your service to the production environment than to deploy it directly there. For more information on swapping VIPs
-
Click either Deploy to production environment or Deploy to stage environment.
-
If you do not want the service to run once it is deployed, clear Start after successful deployment.
-
In Deployment name, type a name for this deployment.
-
In Package Location, click Browse, go to your application directory, and click the service package (cspkg) file.
-
In Configuration file, click Browse, and then click the ServiceConfiguration.cscfg file.
-
Click OK.
Delete a Hosted Service from Windows Azure
Use the following procedure to delete a hosted service from Windows Azure by using the Windows Azure Platform Management Portal. Before you can delete a service, you must delete each of its current service deployments.
To delete a hosted service, you must be either the service administrator or a co-administrator for the Windows Azure subscription that was used to deploy the service.
To delete a hosted service from Windows Azure-
Log into the Windows Azure Platform Management Portal.
-
In the navigation pane, click Hosted Services, Storage Accounts and CDN.
-
At the top of the navigation pane, click Hosted Services.
The items list displays all hosted services for which you are an administrator, sorted by subscription. Beneath each service, each service deployment is listed. Before you can delete the service, you must delete all current deployments of the service.
-
If needed, delete each service deployment for the service.
To delete a service deployment:
- In the items list, expand the subscription, expand the hosted service, and then click the service deployment to select it.
- Stop the service deployment if it is running. To do this, click the service deployment to select it. On the ribbon, in the Service Deployment group, click Stop. Then wait until the service deployment's status changes to Stopped.
- With the service deployment still selected, on the ribbon, in the Service Deployment group, click Delete. The deletion process might take several minutes to complete.
- In the items list, expand the subscription, expand the hosted service, and then click the service deployment to select it.
-
To delete the service, in the items list, click the service to select it. Then, on the ribbon, in the Service group, click Delete.
-
At the confirmation prompt, click OK.
HAPPY CODING