Upload directory in Azure file storage

Dear Team,
we have a requirement to upload folder to Azure file storage using nuget package. could you guide me to how to implement this deployment using Octopus?

Our requirement is:
we have a ‘Releases’ cloud directory in Azure file storage (file service) where we hosting every new releases(as a directory) in this cloud directory.
cloud directory structure like:

  • Releases (cloud directory)
    • Release.4.8 (cloud directory)
    • Release.4.7 (cloud directory)
    • Release.4.6 (cloud directory)
    • Release.4.5 (cloud directory)
      we want to upload new release directory in ‘Releases’ cloud directory whenever we making the new release.
      could you guide me to upload using nuget package (new release contents as nuget package) or directly upload?

Hi,

Thanks for reaching out.

There’s no built-in way to do this from Octopus, so you’re basically gonna have to Powershell your way around it. What you could do is:

  1. Deploy the contents of your Nuget Package to a Custom Installation Directory

  2. Use Powershell to push the content extracted to the Custom install dir to your Azure storage account: https://azure.microsoft.com/en-us/documentation/articles/storage-powershell-guide-full/ . You can use the “Azure Powershell Script” step type we introduced in 3.3, which will already load the Azure PS module and your Azure subscription, so all you’ll have to do is add the script.

Hope that helps,
Dalmiro

Hi,
Thanks for your reply. i have implemented as per your suggestion. Here i have tried to push the content using ‘azure powershell script’. I am getting the following error while running the command through octopus powershell script option.
Get-AzureStorageShare : The remote server returned an error: (403) Forbidden. HTTP Status Code: 403 - HTTP Error Message:
Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.

At C:\Octopus\Work\20160519061210-40\Script.ps1:18 char:6
11:42:15Error

  • $s = Gew-AzureStorageShare -Name ‘deployrootdev’ -Context $ctx.

i didn’t get any issue while running same command in windows powershell window.

could you give to comment for this issue…

Hi,

That 403 error says that the Azure account that’s being used to run that cmdlet doesn’t have enough permissions in your Azure subscription. Is that possible? Perhaps the account that you used from the Powershell console on your local machine has higher privileges than the one configured in Octopus?

Also the error shows the cmdlet Ge*W*-AzureStorageShare . Maybe you have a typo in there as well?

Regards,
Dalmiro

Hi Dalmiro,
Thanks for you reply.
No. Same Azure powershell script is placed in the bamboo build inline script and it is working without any issue. i am only getting the issue when running from octopus powershell options.

if octopus is need higher privileges then , how can i assign high configuration in octopus?

**** GeW-AzureStorageShare - this is copy paste error.

Actual error is:
Get-AzureStorageShare : The remote server returned an error: (403) Forbidden.
HTTP Status Code: 403 - HTTP Error Message: Server failed to authenticate the request.
Make sure the value of Authorization header is formed correctly including the signature.
At C:\Octopus\Work\20160519112446-62\Script.ps1:14 char:6

  • $s = Get-AzureStorageShare -Name deployrootdev -Context $ctx
  •  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    

16:54:50Error
+ CategoryInfo : CloseError: (:slight_smile: [Get-AzureStorageShare], Storage
Exception
+ FullyQualifiedErrorId : StorageException,Microsoft.WindowsAzure.Commands
.Storage.File.Cmdlet.GetAzureStorageShare
The step failed: The remote script failed with exit code 1

Octopus relies on the Azure account registered under Environments -> Accounts to authenticate with Azure. Then, in your azure step you choose which account you want to use. That’s the account that you need to make sure has the right privileges to run your cmdlet. See attached screenshots to get a better understanding of what I’m talking about.

Since you are running the same script in bamboo without problems, something tells me you already have an account setup in the VM that runs your Bamboo jobs. You can run a bamboo build that runs the script Get-AzureAccount to see which account is bamboo using when running azure cmdlets.

Hi Dalimiro,
i have other two azure web api account which was deployed through octopus. i didn’t any issue of those two deployment (which was used ‘Deploy an Azure web app’ option. it is working without any issue. i have followed same procedure for creating Azure storage file account here.
i am getting the exception in powershell script here.
i have implemented the below two lines in powershell script. The first line is running without any issue. i am getting issue only in second line…
$ctx = New-AzureStorageContext $StorageName $Key

$s = Get-AzureStorageShare -Name deployrootdev -Context $ctx

In bamboo, i didn’t do any new changes any setting/privileges for azure implementation. i have installed Azure powershell module in my build server agent pc.

Hi Dalimiro,
do you have any answer for the above post.

Hi Senthil,

Apologies for the delay here. I’m kind of out of ideas given the fact that the error is so straightforward as (403) Forbidden..

I’m gonna try to setup an Azure shared storage and test this on my end to see If i can get it working. I’ll get back to you as soon as I do that, which will most likely be tomorrow morning.

Best regards,
Dalmiro

Hi Senthil,

I’m having a bit of a problem creating the shared storage, even from the Azure portal (which is not the friendliest interface). Could you show me a screenshot of your Shared Storage account from the Azure portal so I know I’m creating the exact same as you.

Unfortunately the Microsoft documentation is a bit vague around this Shared Storage feature. If you can send me ascreenshot of it, I’d know I’m creating the same thing you are using on your end, which will allow me to properly test this.

Regards,
Dalmiro