Resource not found error when deploying

We are having deployment to classic cloud service. We have migrated the storage account from classic to ARM. We have the following code in our Pre-deployment script of Deploy Cloud Service step :
$DeploymentParametersPath = split-path #{Octopus.Action.Azure.CloudServicePackagePath}
Write-Output “Octopus.DeploymentId=#{Octopus.Deployment.Id}” | Out-File $DeploymentParametersPath\LocalContent\XXXX\approot\DeploymentParameters.txt
**Write-Host “Call Invoke-CloudServiceTransform…” **
Invoke-CloudServiceTransform true

We could see from the log file that it prints the Call Invoke-CloudServiceTransform
but however fails after that.

Pasting the following error below. Require your urgent help to sort this out:
Microsoft.WindowsAzure.CloudException: ResourceNotFound: The storage account ‘XXXXX’ was not found.
18:17:33Error
at Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
18:17:33Error
at Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task task)
18:17:33Error
at Microsoft.WindowsAzure.StorageAccountOperationsExtensions.GetKeys(IStorageAccountOperations operations, String accountName)
18:17:33Error
at Calamari.Azure.Integration.AzurePackageUploader.GetStorageAccountPrimaryKey(SubscriptionCloudCredentials credentials, String storageAccountName) in C:\TeamCity\BuildAgent\work\14ffc968155e4956\source\Calamari.Azure\Integration\AzurePackageUploader.cs:line 124
18:17:33Error
at Calamari.Azure.Integration.AzurePackageUploader.Upload(SubscriptionCloudCredentials credentials, String storageAccountName, String packageFile, String uploadedFileName) in C:\TeamCity\BuildAgent\work\14ffc968155e4956\source\Calamari.Azure\Integration\AzurePackageUploader.cs:line 22
18:17:33Error
at Calamari.Azure.Deployment.Conventions.UploadAzureCloudServicePackageConvention.Install(RunningDeployment deployment) in C:\TeamCity\BuildAgent\work\14ffc968155e4956\source\Calamari.Azure\Deployment\Conventions\UploadAzureCloudServicePackageConvention.cs:line 40
18:17:33Error
at Calamari.Deployment.ConventionProcessor.RunInstallConventions() in C:\TeamCity\BuildAgent\work\14ffc968155e4956\source\Calamari\Deployment\ConventionProcessor.cs:line 60
18:17:33Error
at Calamari.Deployment.ConventionProcessor.RunConventions() in C:\TeamCity\BuildAgent\work\14ffc968155e4956\source\Calamari\Deployment\ConventionProcessor.cs:line 28
18:17:33Error
Running rollback conventions…
18:17:33Error
Microsoft.WindowsAzure.CloudException: ResourceNotFound: The storage account ‘prdeadiscostg’ was not found.
18:17:33Error
at Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
18:17:33Error
at Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task task)
18:17:33Error
at Microsoft.WindowsAzure.StorageAccountOperationsExtensions.GetKeys(IStorageAccountOperations operations, String accountName)
18:17:33Error
at Calamari.Azure.Integration.AzurePackageUploader.GetStorageAccountPrimaryKey(SubscriptionCloudCredentials credentials, String storageAccountName) in C:\TeamCity\BuildAgent\work\14ffc968155e4956\source\Calamari.Azure\Integration\AzurePackageUploader.cs:line 124
18:17:33Error
at Calamari.Azure.Integration.AzurePackageUploader.Upload(SubscriptionCloudCredentials credentials, String storageAccountName, String packageFile, String uploadedFileName) in C:\TeamCity\BuildAgent\work\14ffc968155e4956\source\Calamari.Azure\Integration\AzurePackageUploader.cs:line 22
18:17:33Error
at Calamari.Azure.Deployment.Conventions.UploadAzureCloudServicePackageConvention.Install(RunningDeployment deployment) in C:\TeamCity\BuildAgent\work\14ffc968155e4956\source\Calamari.Azure\Deployment\Conventions\UploadAzureCloudServicePackageConvention.cs:line 40
18:17:33Error
at Calamari.Deployment.ConventionProcessor.RunInstallConventions() in C:\TeamCity\BuildAgent\work\14ffc968155e4956\source\Calamari\Deployment\ConventionProcessor.cs:line 60
18:17:33Error
at Calamari.Deployment.ConventionProcessor.RunConventions() in C:\TeamCity\BuildAgent\work\14ffc968155e4956\source\Calamari\Deployment\ConventionProcessor.cs:line 50
18:17:33Error
at Calamari.Azure.Commands.DeployAzureCloudServiceCommand.Execute(String[] commandLineArguments) in C:\TeamCity\BuildAgent\work\14ffc968155e4956\source\Calamari.Azure\Commands\DeployAzureCloudServiceCommand.cs:line 96
18:17:33Error
at Calamari.Program.Execute(String[] args) in C:\TeamCity\BuildAgent\work\14ffc968155e4956\source\Calamari\Program.cs:line 38
18:17:33Fatal
Deploy cloud service - XXXXX on the Octopus Server

Good morning @krishnaprasad.janakiraman,

Thank you for contacting Octopus Support and welcome to the forums, I am sorry one of your deployments is failing.

I can see in the logs the errors:

Microsoft.WindowsAzure.CloudException: ResourceNotFound: The storage account ‘XXXXX’ was not found.

Microsoft.WindowsAzure.CloudException: ResourceNotFound: The storage account ‘prdeadiscostg’ was not found.

Unfortunately this just looks like the script is unable to find the storage account prdeadiscostg.

This seems more of a connection issue rather than an Octopus issue, I did have a quick google and found this article here:

Which then lead me to this:

In the stack overflow article though there are a few bits in there about different calls for different storage accounts depending on where they are located and you did mention you changed the storage from the Azure Classic service and have moved it to ARM so you may just need to change your script to accommodate for that change:

Set-AzureSubscription Cmdlet expects the storage account specified via -CurrentStorageAccount parameter to be a classic storage account.
Please make sure that you’re specifying a classic storage account’s name and not a resource manager storage account’s name.

Hopefully that helps but this does look like a connection error to that storage account via the azure commands you are using, if you are struggling I would run the script outside of Octopus and see if you get the same error. If you do it would rule out Octopus as the issue and you could work on changing your script.

Kind Regards,
Clare

Hi Clare Martin,

Thanks for your quick response.

The deployment has been working earlier for the same storage account(except that it was classic cloud storage) and there has been no change in the steps.

Let me know if we are missing any configuration.

Our configuration looks like this earlier and now as well:

General Information

Hey @krishnaprasad.janakiraman,

Whilst we are familiar with the Octopus plugin for Team City we are not very familiar with the different Azure storage accounts and what code you need to use for each one I am afraid.

You mentioned this was working earlier and after moving the storage account from classic to ARM you are now seeing issues, that does back up what I mentioned previously as Azure apparently expects different commands to be used if you want to connect to azure storage hosted in classic or hosted in ARM.

It looks like you have a variable setup for your storage account so I cant see what the code is for that but Octopus would not be able to advise you in that area unfortunately.

Do you need to configure the storage account in here (go to the Title - Configuring artifact storage)

I am not sure what runner type you are using in your screenshot above either, that is not an Octopus plugin step and it seems I don’t have that option in my Team City for the runner types I have for when I click on ‘Build Step’.

Is that an Azure Team City plugin you are using, if it is you might want to contact Azure as we can only advice on Octopus Plugin Team City Steps.

I look forward to hearing from you,
Kind Regards,
Clare

Let me know if we can have a call scheduled to just quickly run you over through the settings. I work in IST(Indian Standard Time)

Hey @krishnaprasad.janakiraman,

I did discuss this in our Support team meeting and although that does seem like it is our plugin the error itself is coming from Azure so we are unable to help you there.

The easiest thing to do would be to grab the script you are using for this deployment and try running it outside of Octopus. You mentioned you didn’t change the step but you changed where your storage account is located so you would need to change your script, we cannot help you with that I am afraid.

If your script works outside of Octopus we may be able to take a look at why its failing using Octopus but that error is coming from your Azure script not from Octopus so it would be worth checking your script outside of Octopus to see if you get the same error.

If you do one of the websites I linked above should help you get to where you need to to deploy successfully, either that or Azure might be able to help.

If this works outside of Octopus let us know and we can grab some more logs from you and see why this is not working inside of Octopus.

I look forward to hearing from you,
Kind Regards,
Clare

Hi @clare.martin ,

Thanks for your quick reply. I could see that the error starts populating from Calamari tool when it tries to Upload the package. Attaching detailed log file after removing few confidential information and replacing them with XXX and YYY accordingly. You could see that from my older image, the information Call Invoke-CloudServiceTransform is being printed (highlighted in bold below) and also the error starts to popup on calling Calamari.Azure.Integration.AzurePackageUploader.GetStorageAccountPrimaryKey(SubscriptionCloudCredentials credentials, String storageAccountName) in C:\TeamCity\BuildAgent\work\14ffc968155e4956\source\Calamari.Azure\Integration\AzurePackageUploader.cs:line 124**(highlighted the same in bold below)**.

So my assumption here is, Is it because of the cmdlet Invoke-CloudServiceTransform? if assume so, can you let me know any other cmdlet to be used. If you think it is not because of that, could you let me know a sample step that I should be performing for only deployment of cloud service that has storage account updated to ARM.

Attq

Deploying package: F:\Octopus\Packages\XXX.Host\XXX.Host.4.6.0.nupkg
18:17:27Info
Call Invoke-CloudServiceTransform…
18:17:27Info
Invoking function Invoke-CloudServiceTransform
18:17:27Info
Updating config file named ServiceConfiguration.Cloud.cscfg for instance and certificate values
18:17:27Info
Checking Octopus variables for the variables on format:
18:17:27Info

  • Azure.Role[roleName].Instances
    18:17:27Info
  • Azure.Role[roleName].Certificate
    18:17:27Info
    Found 1 roles for instance update
    18:17:27Info
    Found 1 roles for certificate update
    18:17:28Info
    Updating Certificate named devtest.cloudapp.net for XXX.WorkerRole
    18:17:28Info
  • thumprint 137779C94EEE009A5E5852508B70A004011DBF77
    18:17:28Info
    Updating instance count for role XXX.WorkerRole to 2
    18:17:28Info
    ServiceConfiguration.Cloud.cscfg updated!
    18:17:28Info
    Updating definition file named ServiceDefinition\ServiceDefinition.csdef for VM Size values
    18:17:28Info
    Checking Octopus variables for the variables on format:
    18:17:28Info
  • Azure.Role[roleName].VmSize
    18:17:28Info
    Found 1 roles for VM Size update
    18:17:28Info
    roleNode in definition file is WorkerRole
    18:17:28Info
    Updating VM size for role XXX.WorkerRole From ExtraLarge to ExtraLarge
    18:17:28Info
    ServiceDefinition.csdef updated!
    18:17:29Info
    There is no current deployment of service ‘prd-ea-xxx-host’ in slot ‘Staging’, so existing instance counts will not be imported.
    18:17:29Info
    Updating setting for role XXX.WorkerRole: Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString = DefaultEndpointsProtocol=https;AccountName=XXX;AccountKey=XXX;EndpointSuffix=core.windows.net
    18:17:29Info
    Updating appSettings, applicationSettings, and connectionStrings in: F:\Octopus\Work\20230516124708-28\staging\LocalContent\XXX.WorkerRole\approot\XXX.WorkerRole.exe.config
    18:17:29Info
    No matching appSetting, applicationSetting, nor connectionString names were found in: F:\Octopus\Work\20230516124708-28\staging\LocalContent\XXX.WorkerRole\base\x64\WaHostBootstrapper.exe.config
    18:17:29Info
    No matching appSetting, applicationSetting, nor connectionString names were found in: F:\Octopus\Work\20230516124708-28\staging\LocalContent\XXX.WorkerRole\base\x64\WaWorkerHost.exe.config
    18:17:29Info
    No matching appSetting, applicationSetting, nor connectionString names were found in: F:\Octopus\Work\20230516124708-28\staging\LocalContent\XXX.WorkerRole\base\x86\WaHostBootstrapper.exe.config
    18:17:32Info
    Uploading package to Azure blob storage: ‘F:\Octopus\Work\20230516124708-28\staging\YYY.CloudHost.cspkg’
    18:17:32Error
    Microsoft.WindowsAzure.CloudException: ResourceNotFound: The storage account ‘XXX’ was not found.
    18:17:33Error
    at Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
    18:17:33Error
    at Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task task)
    18:17:33Error
    at Microsoft.WindowsAzure.StorageAccountOperationsExtensions.GetKeys(IStorageAccountOperations operations, String accountName)
    18:17:33Error
    at Calamari.Azure.Integration.AzurePackageUploader.GetStorageAccountPrimaryKey(SubscriptionCloudCredentials credentials, String storageAccountName) in C:\TeamCity\BuildAgent\work\14ffc968155e4956\source\Calamari.Azure\Integration\AzurePackageUploader.cs:line 124
    18:17:33Error
    at Calamari.Azure.Integration.AzurePackageUploader.Upload(SubscriptionCloudCredentials credentials, String storageAccountName, String packageFile, String uploadedFileName) in C:\TeamCity\BuildAgent\work\14ffc968155e4956\source\Calamari.Azure\Integration\AzurePackageUploader.cs:line 22

    18:17:33Error
    at Calamari.Azure.Deployment.Conventions.UploadAzureCloudServicePackageConvention.Install(RunningDeployment deployment) in C:\TeamCity\BuildAgent\work\14ffc968155e4956\source\Calamari.Azure\Deployment\Conventions\UploadAzureCloudServicePackageConvention.cs:line 40
    18:17:33Error
    at Calamari.Deployment.ConventionProcessor.RunInstallConventions() in C:\TeamCity\BuildAgent\work\14ffc968155e4956\source\Calamari\Deployment\ConventionProcessor.cs:line 60
    18:17:33Error
    at Calamari.Deployment.ConventionProcessor.RunConventions() in C:\TeamCity\BuildAgent\work\14ffc968155e4956\source\Calamari\Deployment\ConventionProcessor.cs:line 28
    18:17:33Error
    Running rollback conventions…
    18:17:33Error
    Microsoft.WindowsAzure.CloudException: ResourceNotFound: The storage account ‘XXX’ was not found.
    18:17:33Error
    at Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
    18:17:33Error
    at Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task task)
    18:17:33Error
    at Microsoft.WindowsAzure.StorageAccountOperationsExtensions.GetKeys(IStorageAccountOperations operations, String accountName)
    18:17:33Error
    at Calamari.Azure.Integration.AzurePackageUploader.GetStorageAccountPrimaryKey(SubscriptionCloudCredentials credentials, String storageAccountName) in C:\TeamCity\BuildAgent\work\14ffc968155e4956\source\Calamari.Azure\Integration\AzurePackageUploader.cs:line 124
    18:17:33Error
    at Calamari.Azure.Integration.AzurePackageUploader.Upload(SubscriptionCloudCredentials credentials, String storageAccountName, String packageFile, String uploadedFileName) in C:\TeamCity\BuildAgent\work\14ffc968155e4956\source\Calamari.Azure\Integration\AzurePackageUploader.cs:line 22
    18:17:33Error
    at Calamari.Azure.Deployment.Conventions.UploadAzureCloudServicePackageConvention.Install(RunningDeployment deployment) in C:\TeamCity\BuildAgent\work\14ffc968155e4956\source\Calamari.Azure\Deployment\Conventions\UploadAzureCloudServicePackageConvention.cs:line 40
    18:17:33Error
    at Calamari.Deployment.ConventionProcessor.RunInstallConventions() in C:\TeamCity\BuildAgent\work\14ffc968155e4956\source\Calamari\Deployment\ConventionProcessor.cs:line 60
    18:17:33Error
    at Calamari.Deployment.ConventionProcessor.RunConventions() in C:\TeamCity\BuildAgent\work\14ffc968155e4956\source\Calamari\Deployment\ConventionProcessor.cs:line 50
    18:17:33Error
    at Calamari.Azure.Commands.DeployAzureCloudServiceCommand.Execute(String[] commandLineArguments) in C:\TeamCity\BuildAgent\work\14ffc968155e4956\source\Calamari.Azure\Commands\DeployAzureCloudServiceCommand.cs:line 96
    18:17:33Error
    at Calamari.Program.Execute(String[] args) in C:\TeamCity\BuildAgent\work\14ffc968155e4956\source\Calamari\Program.cs:line 38
    18:17:33Fatal
    Deploy cloud service - XXX on the Octopus Server

Hey @krishnaprasad.janakiraman,

Unfortunately that error you are seeing is coming from Calamari but it is erroring because of the initial azure error:

Microsoft.WindowsAzure.CloudException: ResourceNotFound: The storage account ‘XXXXX’ was not found.

If the script you are running cannot find the storage account then Octopus also will not be able to find it and wont be able to upload any packages to it.

In the logs where you have highlighted the error code you can see this above where you have highlighted:

18:17:32Info
Uploading package to Azure blob storage: ‘F:\Octopus\Work\20230516124708-28\staging\YYY.CloudHost.cspkg’
18:17:32Error
Microsoft.WindowsAzure.CloudException: ResourceNotFound: The storage account ‘XXX’ was not found.

You would still need to fix that initial Azure error so the script can find your storage account, this would not be something Octopus can help with unfortunately.

Did you manage to run the script outside of Octopus and did that run fine? You need to get this working outside of Octopus so that script you are running finds the storage account, only then will Octopus be able to upload packages to it.

Kind Regards,
Clare

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.