Click here to Skip to main content
13,342,876 members (57,442 online)
Click here to Skip to main content
Add your own
alternative version


3 bookmarked
Posted 23 Dec 2012

Windows Azure Application Package New Format

, 24 Dec 2012
Rate this:
Please Sign up or sign in to vote.
Create Azure cloud service application in OPC format


You probably found yourself rebuilding your Windows Azure application just to make a small modification in the application configuration.
For example, let's say that your initial design was to set for each Role instance a virtual machine size of Small VM (1 CPU).

Along the way, you noticed that the initial VM size was just not enough and the Role instances need a bigger VM.
The common way to fix that is to just open Visual Studio and change the application service definition configurations that will be eventually reflected in the ServiceDefinition.csdefe file under <WebRole name=[WebRoleName] vmsize=[VM_SIZE]>.

It would have been easier if you could have opened the application package and made the changes without the need for the development environment.
In addition, it's a valid option that you as the DevOp just don't have access to the application source code and application provisioning is an issue that needs to be addressed on a closed application package file.

The trouble with the application package old format is that the file content is encrypted (using the Azure SDK) and cannot be edited.
Luckily, Windows Azure provides a way to use an open format (OPC) application package that can be opened with simple archive tools such as WinZip or WinRaR in order to modify specific files.

In this post, I would demonstrate how to create an application package with the new format using a simple PowerShell script.

First let's quickly cover the parts that assemble an Azure application.

Application Package Old vs New Format

Every application package contains 2 files:

  1. *.cspkg - application code which includes the important ServiceDefinition.csdefe file mentioned above
  2. ServiceConfiguration.cscfg

Using the Code

In the CSPack command line tool, Microsoft added 2 new options for supporting the new package format:

  1. /useCtpPackageFormat - creates the new OPC application package format
  2. /convertToCtpPackage - converts the application package old to new format

The code below creates the Azure application in an OPC format: (The CSPack command can be found in the following path: C:\Program Files\Microsoft SDKs\Windows Azure\.NET SDK\<sdk-version>\bin).

# Working script parms
$cppack = 'C:\Program Files\Microsoft SDKs\Windows Azure\.NET SDK\2012-10\bin\cspack.exe'
$workingDir = "C:\Users\[USER_NAME]\Documents\Visual Studio 2010\Projects\TestDepOneRole"
$serviceName = "TestDepOneRole"
$roleName = "WebRole1Update"
$roleBinDir = [string]::Format("{0}\{1}",$workingDir,"WebRole1")
$outPath = [string]::Format("{0}\{1}",$workingDir,"packages")
# CSPack command parms
$_serviceDefinitionPath = 
$_serviceConfigurationPath = 
$_role = [string]::Format("/role:{0};{1}", $roleName,$roleBinDir)
$_sites = [string]::Format("/sites:{0};Web;{1}",$roleName,$roleBinDir) 
$_out = [string]::Format("/out:{0}\package\{1}OPC.cspkg",$workingDir,$serviceName)
# Running script
if(!(test-path $outPath -pathtype container)){
    new-item -Name "package" -ItemType directory -Path $workingDir
& $cppack $_serviceDefinitionPath $_role $_sites $_out /useCtpPackageFormat
Copy-Item $_serviceConfigurationPath $outPath 

Opening the file using WinRaR reveals the following:

You can notice that the service definition can be edited and inserted back to the application package to submit the changes.

Points of Interest

The OPC format should be used well in Azure for static content editing, for example, modifying external properties files in the application package. However, in the current implementation, the OPC does not resemble the structure you would expect from the cloud solution.

For example, the LocalContent folder contains hash files that cannot be extracted and there isn't a proper directory structure like in Visual Studio cloud project so editing a simple CSS file is not yet possible.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Shay Yannay
Software Developer Quest Software
Israel Israel
Shay Yannay is a Senior Software Developer and Windows Azure Domain Expert.
He is experienced with designing and developing highly scalable, distributed, 24x7 availability complex system. Shay also specializes in performance management & diagnostics of multi-tier applications.
He is passionate about the cloud technologies and trends, specifically with Microsoft Azure.
He currently works for Dell as an Azure Specialist.

Shay holds a B.Sc in Communication Systems Engineering from the Ben-Gurion university.

Personal Blog:

You may also be interested in...


Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.180111.1 | Last Updated 24 Dec 2012
Article Copyright 2012 by Shay Yannay
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid