Uri error when deploying to Azure cloud service

Hi,

When I attempt to deploy to an Azure cloud service from Octopus, I get this error:

System.ArgumentException: Part URI is not valid per rules defined in the Open Packaging Conventions specification.
October 14th 2016 12:22:05Error
at System.IO.Packaging.PackUriHelper.ValidatePartUri(Uri partUri)
October 14th 2016 12:22:05Error
at System.IO.Packaging.Package.GetPartHelper(Uri partUri)
October 14th 2016 12:22:05Error
at System.IO.Packaging.Package.GetPart(Uri partUri)
October 14th 2016 12:22:05Error
at Microsoft.WindowsAzure.Packaging.PackageConverter.AddSoftwarePackageToLayout(PackageBuilder builder, String layoutPath, ServiceSoftwarePackage softwarePacakge)
October 14th 2016 12:22:05Error
at Microsoft.WindowsAzure.Packaging.PackageConverter.ConvertFromLegacy(Stream srcPackage, PackageStore dstPackage, X509Certificate2 decrypt, PackageRestrictions restrictions)
October 14th 2016 12:22:05Error
at Calamari.Azure.Deployment.Conventions.EnsureCloudServicePackageIsCtpFormatConvention.ConvertPackage(String packagePath) in Z:\BuildAgent\work\14ffc968155e4956\source\Calamari.Azure\Deployment\Conventions\EnsureCloudServicePackageIsCtpFormatConvention.cs:line 48
October 14th 2016 12:22:05Error
at Calamari.Azure.Deployment.Conventions.EnsureCloudServicePackageIsCtpFormatConvention.Install(RunningDeployment deployment) in Z:\BuildAgent\work\14ffc968155e4956\source\Calamari.Azure\Deployment\Conventions\EnsureCloudServicePackageIsCtpFormatConvention.cs:line 38
October 14th 2016 12:22:05Error
at Calamari.Deployment.ConventionProcessor.RunInstallConventions() in Z:\BuildAgent\work\14ffc968155e4956\source\Calamari\Deployment\ConventionProcessor.cs:line 60
October 14th 2016 12:22:05Error
at Calamari.Deployment.ConventionProcessor.RunConventions() in Z:\BuildAgent\work\14ffc968155e4956\source\Calamari\Deployment\ConventionProcessor.cs:line 28
October 14th 2016 12:22:05Error
Running rollback conventions…
October 14th 2016 12:22:05Error
System.ArgumentException: Part URI is not valid per rules defined in the Open Packaging Conventions specification.
October 14th 2016 12:22:05Error
at System.IO.Packaging.PackUriHelper.ValidatePartUri(Uri partUri)
October 14th 2016 12:22:05Error
at System.IO.Packaging.Package.GetPartHelper(Uri partUri)
October 14th 2016 12:22:05Error
at System.IO.Packaging.Package.GetPart(Uri partUri)
October 14th 2016 12:22:05Error
at Microsoft.WindowsAzure.Packaging.PackageConverter.AddSoftwarePackageToLayout(PackageBuilder builder, String layoutPath, ServiceSoftwarePackage softwarePacakge)
October 14th 2016 12:22:05Error
at Microsoft.WindowsAzure.Packaging.PackageConverter.ConvertFromLegacy(Stream srcPackage, PackageStore dstPackage, X509Certificate2 decrypt, PackageRestrictions restrictions)
October 14th 2016 12:22:05Error
at Calamari.Azure.Deployment.Conventions.EnsureCloudServicePackageIsCtpFormatConvention.ConvertPackage(String packagePath) in Z:\BuildAgent\work\14ffc968155e4956\source\Calamari.Azure\Deployment\Conventions\EnsureCloudServicePackageIsCtpFormatConvention.cs:line 48
October 14th 2016 12:22:05Error
at Calamari.Azure.Deployment.Conventions.EnsureCloudServicePackageIsCtpFormatConvention.Install(RunningDeployment deployment) in Z:\BuildAgent\work\14ffc968155e4956\source\Calamari.Azure\Deployment\Conventions\EnsureCloudServicePackageIsCtpFormatConvention.cs:line 38
October 14th 2016 12:22:05Error
at Calamari.Deployment.ConventionProcessor.RunInstallConventions() in Z:\BuildAgent\work\14ffc968155e4956\source\Calamari\Deployment\ConventionProcessor.cs:line 60
October 14th 2016 12:22:05Error
at Calamari.Deployment.ConventionProcessor.RunConventions() in Z:\BuildAgent\work\14ffc968155e4956\source\Calamari\Deployment\ConventionProcessor.cs:line 50
October 14th 2016 12:22:05Error
at Calamari.Azure.Commands.DeployAzureCloudServiceCommand.Execute(String[] commandLineArguments) in Z:\BuildAgent\work\14ffc968155e4956\source\Calamari.Azure\Commands\DeployAzureCloudServiceCommand.cs:line 97
October 14th 2016 12:22:05Error
at Calamari.Program.Execute(String[] args) in Z:\BuildAgent\work\14ffc968155e4956\source\Calamari\Program.cs:line 38
October 14th 2016 12:22:05Fatal
The remote script failed with exit code 100
October 14th 2016 12:22:05Fatal
Deploy to Cloud Service on the Octopus Server

Can you please assist.

Regards

Hi Darcy,

Thanks for getting in touch! I’m sorry you’ve run into this problem. I found a similar thread from last year where someone was able to resolve this exact problem: http://help.octopusdeploy.com/discussions/problems/39033-part-uri-is-not-valid-per-rules-defined-in-the-open-packaging-conventions-specification

If this isn’t helpful, please don’t hesitate to get back in touch. :slight_smile:

Hope this helps!
Mike

Hi Mike,

This is really holding me up and using a lot of my time. This error only
seems to be occurring since I updated Octopus from version 3.3* to 3.4*.

Any chance you have found out what is causing the error?

Cheers,
Darcy

Hi Darcy,

Thanks for getting back to me. Did you try the steps described in the other thread I linked? Did you have any invalid file names? If so, we don’t have any other option but to rename the files, or disable cspkg extraction.

If you haven’t gone through the other thread, Paul describes the steps you can use to find a file that might have an invalid filename.

Alternatively you could send us the .cspkg file and I’ll try to reproduce the problem.

In the mean time, there are two options you can try:

  1. Rename the files to remove any invalid characters. I’m not sure if there are other conventions you can use with MVC to keep the array syntax out of the file name.
  2. Disable package extraction in Octopus. This means that we won’t be able to run transforms on your web.config files or change web.config settings, but we can still make changes to .cscfg.

To disable package extraction, create a new variable for your project in Octopus with the following name:

Octopus.Action.Azure.CloudServicePackageExtractionDisabled

And set the value to True.

Hope that helps!
Mike

Hi Mike,

Thanks for the reply however it doesn’t resolve my issue.

This is a definite but in your system. However, it can be resolved by
making the cspkg file a ctp format. You guys need to provide workaround
documentation for this whilst the bug is resolved.

Cheers,
Darcy

Hi Darcy,

Thanks for getting back to me. I’m really sorry, I can’t replicate the behaviour you are seeing without having a better idea of the root cause.

When we deploy a Cloud Service, we recognise the package needs to be converted before pushing to Azure (if it’s a Legacy format), and use the Azure SDK to perform the conversion:

It sounds like you’ve worked around the issue by performing the package format conversion using cspack.exe yourself? Perhaps something like this?

If that is the case, can you confirm which version of the Azure SDK you used to perform the conversion? We are currently using Azure SDK 2.6, so one potential change we can make is to upgrade our dependency to that version, or to the latest available version being Azure SDK 2.9.5.

In the meantime I’d be happy to add some pointers to our documentation. I would really appreciate it if you could briefly list the steps you took to work around the problem, and I’ll share them until we find a more permanent solution.

Hope that helps!
Mike