Visual Studio Deployment Projects and Octopus Integration

1.I would like to test my deployment projects via Visual studio
2.Package my deployment projects
3.Trigger them using variables that are stored in octopus.

Right now when I try to deploy using Visual studio I am getting this error. Would love to have an example for this.

I have got 2 files
1.Template ( parameters(defaultvalues),variables,resources)
2.Parameters ( parameters)

14:50:35 - [ERROR] New-AzureRmResourceGroupDeployment : 2:50:34 PM - Resource
14:50:35 - [ERROR] Microsoft.Sql/servers ‘variables(‘serverName’)’ failed with message '{
14:50:35 - [ERROR] “code”: “40645”,
14:50:35 - [ERROR] “message”: “Servername “variables(‘serverName’)” cannot be empty or null.
14:50:35 - [ERROR] It can only be made up of lowercase letters ‘a’-‘z’, the numbers 0-9 and the
14:50:35 - [ERROR] hyphen. The hyphen may not lead or trail in the name.”,
14:50:35 - [ERROR] “target”: null,
14:50:35 - [ERROR] “details”: [

This is how I test deployments using Visual Studio

This is how I enter the variables in octopus

I am confused in the parameters file should I say

"servers_replica_name": {
  "value": "variables('replicaServerName')"
}

or

"servers_replica_name": {
  "value": "#{replicaServerName}"
}

When I put back the default values as strings. Now I am getting

[ERROR] New-AzureRmResourceGroupDeployment : 3:17:27 PM - Error: Code=InvalidTemplate;
15:17:27 - [ERROR] Message=Deployment template validation failed: ‘The resource
15:17:27 - [ERROR] ‘Microsoft.Sql/servers/xxxxx’ is not defined in the template. Please see
15:17:27 - [ERROR] https://aka.ms/arm-template for usage details.’.

I am working on the issue. Yesterday I have created a simple parameters file called default. And Cleaned all the parameters there so I can test the default parameters from the visual studio.

I am still not sure how to test the different environments. Should I add a parameters file for each one of them or should I have only one octopus file with generic octopus parameters.

Best practices or a tutorial would tremendously help

Hi,

Thanks for reaching out! Let me try to give you a hand with those questions:

When running steps from Octopus

When developing the template from Visual Studio

  • Those #{variable] variables wont work, so we recommend you to use hard-coded values instead.

In case you haven’t done it already, I recommend you to check our docs about deploying ARM templates with Octopus: https://octopus.com/docs/guides/azure-deployments/resource-groups#deploy-using-an-azure-resource-group-template

Regards,
Dalmiro

Great thanks.