JSON application settings throws System.UnauthorizedAccessException

Hi,

I’m using Octopus 3.3.0-beta0001, in particular the JSON application settings feature.

The Tentacle is running on a remote server under the local system account. That account does have full control permissions for the target file and the folder under which it lives.

I’m using the following settings: -

Generate a JSON file containing Octopus variables = true
Target file = approot\packages\#{Octopus.Project.Name}\#{Octopus.Action[Deploy package].Package.NuGetPackageVersion}\root

I’m getting the following error: -

Applying JSON configuration generation to 
"C:\Octopus\Applications\Staging\MyApplication\1.0.0_5\approot\packages\MyApplication\1.0.0\root"
System.UnauthorizedAccessException: Access to the path 
'C:\Octopus\Applications\Staging\MyApplication\1.0.0_5\approot\packages\MyApplication\1.0.0\root' is denied.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost)
   at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost)
   at System.IO.StreamWriter..ctor(String path)
   at Calamari.Integration.AppSettingsJson.AppSettingsJsonGenerator.SaveJson(String appSettingsFilePath, JObject root) in Y:\work\14ffc968155e4956\source\Calamari\Integration\AppSettingsJson\AppSettingsJsonGenerator.cs:line 95
   at Calamari.Integration.AppSettingsJson.AppSettingsJsonGenerator.Generate(String appSettingsFilePath, VariableDictionary variables) in Y:\work\14ffc968155e4956\source\Calamari\Integration\AppSettingsJson\AppSettingsJsonGenerator.cs:line 29
   at Calamari.Deployment.Conventions.AppSettingsJsonConvention.Install(RunningDeployment deployment) in Y:\work\14ffc968155e4956\source\Calamari\Deployment\Conventions\AppSettingsJsonConvention.cs:line 31
   at Calamari.Deployment.ConventionProcessor.RunInstallConventions() in Y:\work\14ffc968155e4956\source\Calamari\Deployment\ConventionProcessor.cs:line 60
   at Calamari.Deployment.ConventionProcessor.RunConventions() in Y:\work\14ffc968155e4956\source\Calamari\Deployment\ConventionProcessor.cs:line 28
Running rollback conventions...
System.UnauthorizedAccessException: Access to the path 'C:\Octopus\Applications\Staging\MyApplication\1.0.0_5\approot\packages\MyApplication\1.0.0\root' is denied.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost)
   at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost)
   at System.IO.StreamWriter..ctor(String path)
   at Calamari.Integration.AppSettingsJson.AppSettingsJsonGenerator.SaveJson(String appSettingsFilePath, JObject root) in Y:\work\14ffc968155e4956\source\Calamari\Integration\AppSettingsJson\AppSettingsJsonGenerator.cs:line 95
   at Calamari.Integration.AppSettingsJson.AppSettingsJsonGenerator.Generate(String appSettingsFilePath, VariableDictionary variables) in Y:\work\14ffc968155e4956\source\Calamari\Integration\AppSettingsJson\AppSettingsJsonGenerator.cs:line 29
   at Calamari.Deployment.Conventions.AppSettingsJsonConvention.Install(RunningDeployment deployment) in Y:\work\14ffc968155e4956\source\Calamari\Deployment\Conventions\AppSettingsJsonConvention.cs:line 31
   at Calamari.Deployment.ConventionProcessor.RunInstallConventions() in Y:\work\14ffc968155e4956\source\Calamari\Deployment\ConventionProcessor.cs:line 60
   at Calamari.Deployment.ConventionProcessor.RunConventions() in Y:\work\14ffc968155e4956\source\Calamari\Deployment\ConventionProcessor.cs:line 50
   at Calamari.Commands.DeployPackageCommand.Execute(String[] commandLineArguments) in Y:\work\14ffc968155e4956\source\Calamari\Commands\DeployPackageCommand.cs:line 110
   at Calamari.Program.Execute(String[] args) in Y:\work\14ffc968155e4956\source\Calamari\Program.cs:line 38
The remote script failed with exit code 100

Is there something that I’m doing wrong please?

Hi Wayne,

Thanks for the question. From the information you have sent it looks like you are specifying a path as the parameter for the JSON file to be generated. You should specify the file as well. For example:

approot\packages\#{Octopus.Project.Name}\#{Octopus.Action[Deploy package].Package.NuGetPackageVersion}\root\appsettings.json

Please let me know if that helps. I think that error message is misleading, something we can work on.

Cheers,
Shane

That works a treat thank you :slight_smile:

The error message did mislead me I must confess. Your documentation, however, does include the file name in its example so I should’ve spotted that. Perhaps an update to that documentation to inform that the file name is mandatory, regardless of the path used, would be useful.

Thanks for your quick response,
Wayne.