Recreate azure cloud service package with correct instance size from a package having incorrect VM size


Consider a scenario where you’re given azure cloud service packages for deployment and you don’t have access to the code base used to create that package. And in case one of the package’s ServiceDefinition.csdef file has an incorrect VM size mentioned.

In this case, you either have to request for a new package which might take lot of time based on the dev team’s availability or else, you can recreate the package if you have Azure SDK installed in your local machine. This post will explain the steps required to re-create the package with the right size VM in case getting another package is not possible immediately and deployment is time-critical.

Follow below steps to re-create package:

  1. As a backup, take a copy of the incorrectly-sized package. We will work on the copy from now.
  2. Rename the package such that it’s extension is now .ZIP as shown below
  3. Extract the contents of the above created ZIP file into a folder. You should see some 7 items inside as shown below.
  4. Note the file that is highlighted in the above image. the file with the .CDSX extension. You need to update the extension of this file also to .ZIP.
  5. After extracting the above file, open the folder and you will see the ServiceDefinition.csdef file. Edit the file and change the VMSize to the required size. See below.
    3 4
  6. After editing the csdef file, go back to the previous folder and now select and rename the file with .CSSX extension to have a .ZIP extension. This file’s name will start with the rolename. Extract this zip as well. See below
    5 6
  7. Note the highlighted two items in the above extracted zip. The approot folder has all the binaries of the cloudservice that needs to be deployed. And the __entrypoint.txt file has the entry point DLL mentioned in it. Edit the __entrypoint.txt text file to be of the format EntryPoint=dllname.dll. It might not have the initial EntryPoint=, you will have to add it. Otherwise there is a chance of facing exception later on.
  8. Now navigate to the below folder in command prompt.
    C:\Program Files\Microsoft SDKs\Azure\.NET SDK\v2.9\bin
  9. This folder has the cspack.exe that is used to generate cloud packages. Type the below command now to generate the cloud package again. Make sure the role name, quotations and paths are correctly mentioned in the below command.
    cspack.exe “path_to_csdef_File\ServiceDefinition.csdef” /role:<RoleName>;<path_to_Binaries\approot> /out:D:\NewPackage.cspkg /rolePropertiesFile:<rolename>;<path_to_entry_point_file\entrypoint.txt>
  10. The newly created cloud package has the updated VM Size. Deploy this package to update the cloud service to the correct VM size.

Please refer to the below links for more information about cloud packaging.

Hope this helps!!

This entry was posted in .NET, General and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *