Skip to content

Commit a5f0584

Browse files
authored
Adding template compatible with deploying to Flexible Consumtion plans (#1647)
1 parent e347c3d commit a5f0584

1 file changed

Lines changed: 124 additions & 0 deletions

File tree

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
{
2+
"Id": "7517e099-cb94-4254-bdc7-4446b897f7b4",
3+
"Name": "Azure - Deploy Azure App using config-zip",
4+
"Description": "Deploy an Azure App Service (Web App or Function App) using the `config-zip` option. This template is compatible with deploying to Azure App Services that are on the `Flexible Consumption Plan`.",
5+
"ActionType": "Octopus.AzurePowerShell",
6+
"Version": 1,
7+
"CommunityActionTemplateId": null,
8+
"Packages": [
9+
{
10+
"Id": "783596ea-9a68-49c8-9cb8-ad1265893840",
11+
"Name": "Template.Package",
12+
"PackageId": "",
13+
"FeedId": null,
14+
"AcquisitionLocation": "Server",
15+
"Properties": {
16+
"Extract": "True",
17+
"SelectionMode": "deferred",
18+
"PackageParameterName": "Template.Package"
19+
}
20+
}
21+
],
22+
"GitDependencies": [],
23+
"Properties": {
24+
"Octopus.Action.Script.ScriptSource": "Inline",
25+
"Octopus.Action.Script.Syntax": "PowerShell",
26+
"OctopusUseBundledTooling": "False",
27+
"Octopus.Action.Azure.AccountId": "#{Template.Azure.Account}",
28+
"Octopus.Action.EnabledFeatures": "Octopus.Features.JsonConfigurationVariables,Octopus.Features.SubstituteInFiles",
29+
"Octopus.Action.Package.JsonConfigurationVariablesTargets": "#{Template.Replace.StructuredConfigurationVariables.Pattern}",
30+
"Octopus.Action.SubstituteInFiles.TargetFiles": "#{Template.Replace.VariablesInFiles.Pattern}",
31+
"Octopus.Action.Script.ScriptBody": "Write-Host \"Determining Operating System...\"\n# Check to see if $IsWindows is available\nif ($null -eq $IsWindows)\n{\n switch ([System.Environment]::OSVersion.Platform)\n {\n \t\"Win32NT\"\n {\n \t# Set variable\n $IsWindows = $true\n $IsLinux = $false\n }\n \"Unix\"\n {\n \t$IsWindows = $false\n $IsLinux = $true\n }\n }\n}\n\nif ($IsWindows)\n{\n\tWrite-Host \"Detected OS is Windows\"\n $ProgressPreference = 'SilentlyContinue'\n}\nelse\n{\n\tWrite-Host \"Detected OS is Linux\"\n}\n\n# Fix ANSI Color on PWSH Core issues when displaying objects\nif ($PSEdition -eq \"Core\") {\n $PSStyle.OutputRendering = \"PlainText\"\n}\n\n# Get working variables\n$packageExtractedPath = $OctopusParameters['Octopus.Action.Package[Template.Package].ExtractedPath']\n$originalPath = $OctopusParameters['Octopus.Action.Package[Template.Package].OriginalPath']\n$packageId = $OctopusParameters['Octopus.Action.Package[Template.Package].PackageId']\n$packageVersion = $OctopusParameters['Octopus.Action.Package[Template.Package].PackageVersion']\n$azureResourceGroupName = $OctopusParameters['Template.Azure.ResourceGroup.Name']\n$azureServiceName = $OctopusParameters['Template.Azure.Service.Name']\n$azureServiceType = $OctopusParameters['Template.Azure.Service.Type']\n$slotName = $OctopusParameters['Template.Slot.Name']\n\n# Check for Windows\nif ($isWindows)\n{\n ###########\n # Okay, I know this looks really weird, but during development and testing, I found that the method used in the else statement did something weird to the archive where\n # the deployment would fail, claiming the .azurfunctions folder is missing when it is clearly there only on Windows. Grabbing the original file and only updating the changed files\n # from the variable replacement operations and uploading the updated file seems to work\n ###########\n # Grab the original archive file\n Copy-Item -Path $originalPath -Destination \"$PWD/$($packageId).$($packageVersion).zip\"\n\n # Update the original archive with the items from the repackaged one so it includes any replacement\n Compress-Archive -Path \"$packageExtractedPath/*\" -DestinationPath \"$PWD/$($packageId).$($packageVersion).zip\" -Update\n}\nelse\n{\n # Repackage the files\n Get-ChildItem -Path $packageExtractedPath -Force | Compress-Archive -DestinationPath \"$PWD/$($packageId).$($packageVersion).zip\"\n}\n\n$archiveFile = Get-ChildItem -Path \"$PWD/$($packageId).$($packageVersion).zip\"\n\n# Create argument array\n$commandArguments = @()\n\n# Deploy the service\nswitch ($azureServiceType)\n{\n \"functionapp\"\n {\n # Append functionapp specific arguments\n $commandArguments += @(\"functionapp\")\n break\n }\n \"webapp\"\n {\n $commandArguments += @(\"webapp\")\n break\n }\n}\n\n# Add additional arguments\n$commandArguments += @(\"deployment\", \"source\", \"config-zip\", \"--src\", \"$($archiveFile.FullName)\", \"--resource-group\", \"$azureResourceGroupName\", \"--name\", \"$azureServiceName\")\n\n# Check to see if they're using slots\nif (![string]::IsNullOrWhitespace($slotName))\n{\n $commandArguments += @(\"--slot\", \"$slotName\")\n}\n\n# Execute command\nWrite-Host \"Executing: az $commandArguments\"\n\n\n\n# Redirection of stderr to stdout is done different on Windows versus Linux\nif ($IsWindows) {\n $commandArguments += @(\"2>&1\")\n # Execute Liquibase\n az $commandArguments\n}\n\nif ($IsLinux) {\n # Execute Liquibase\n az $commandArguments 2>&1\n}\n\n# Check exit code\nif ($lastExitCode -ne 0) {\n # Fail the step\n Write-Error \"Deployment failed!\"\n}\n\n\n#az $commandArguments"
32+
},
33+
"Parameters": [
34+
{
35+
"Id": "40555b1e-248d-458b-b33d-9cfb6a115998",
36+
"Name": "Template.Azure.Account",
37+
"Label": "Azure Account",
38+
"HelpText": "Choose the Azure account to use when executing this template.",
39+
"DefaultValue": "",
40+
"DisplaySettings": {
41+
"Octopus.ControlType": "AzureAccount"
42+
}
43+
},
44+
{
45+
"Id": "b0a08a4c-b887-4170-ba5b-d4ac9d41b650",
46+
"Name": "Template.Azure.ResourceGroup.Name",
47+
"Label": "Azure Resource Group Name",
48+
"HelpText": "The name of the Azure Resource Group to deploy the App Service to.",
49+
"DefaultValue": "",
50+
"DisplaySettings": {
51+
"Octopus.ControlType": "SingleLineText"
52+
}
53+
},
54+
{
55+
"Id": "d3b07e0e-bc9a-4484-9022-6bd256138d21",
56+
"Name": "Template.Azure.Service.Name",
57+
"Label": "Azure App Service Name",
58+
"HelpText": "The name of the Azure App Service (web app or function app) to deploy.",
59+
"DefaultValue": "",
60+
"DisplaySettings": {
61+
"Octopus.ControlType": "SingleLineText"
62+
}
63+
},
64+
{
65+
"Id": "a82571c5-ab29-438d-81d1-a0b88638b5d7",
66+
"Name": "Template.Azure.Service.Type",
67+
"Label": "Azure App Service Type",
68+
"HelpText": "Select the type of App Service you want to deploy.",
69+
"DefaultValue": "",
70+
"DisplaySettings": {
71+
"Octopus.ControlType": "Select",
72+
"Octopus.SelectOptions": "functionapp|Function App\nwebapp|Web App"
73+
}
74+
},
75+
{
76+
"Id": "a9c66943-b6ff-4a4f-a01f-d0336eb7283d",
77+
"Name": "Template.Azure.Slot.Name",
78+
"Label": "Slot Name",
79+
"HelpText": "(Optional) Name of the slot to deploy to. Leave blank if you're not using slot capabilities.",
80+
"DefaultValue": "",
81+
"DisplaySettings": {
82+
"Octopus.ControlType": "SingleLineText"
83+
}
84+
},
85+
{
86+
"Id": "817164f5-15d4-4813-aceb-b9cc619bec6c",
87+
"Name": "Template.Package",
88+
"Label": "App Service Package",
89+
"HelpText": "The package to deploy.",
90+
"DefaultValue": "",
91+
"DisplaySettings": {
92+
"Octopus.ControlType": "Package"
93+
}
94+
},
95+
{
96+
"Id": "b36e78de-622f-4c5b-9f33-dc770fa14e74",
97+
"Name": "Template.Replace.VariablesInFiles.Pattern",
98+
"Label": "Variable replacement in files pattern",
99+
"HelpText": "This template has the feature of [Substitute Variables in Templates](https://octopus.com/docs/projects/steps/configuration-features/substitute-variables-in-templates) enabled, giving you the ability to replace Octopus Variable place holders in files. You can specify more than one file or pattern, newline separated.",
100+
"DefaultValue": "#{Octopus.Action.Package[Template.Package].ExtractedPath}/*.json",
101+
"DisplaySettings": {
102+
"Octopus.ControlType": "MultiLineText"
103+
}
104+
},
105+
{
106+
"Id": "a42d44b3-c824-41d4-a18e-43cf3a55b458",
107+
"Name": "Template.Replace.StructuredConfigurationVariables.Pattern",
108+
"Label": "Structured configuration variable replacement",
109+
"HelpText": "This template has the [Structured Configuration Variables](https://octopus.com/docs/projects/steps/configuration-features/structured-configuration-variables-feature) feature enabled giving you the ability to replace existing values within files. You can specify more than one file or pattern, newline separated.",
110+
"DefaultValue": "#{Octopus.Action.Package[Template.Package].ExtractedPath}/*.json",
111+
"DisplaySettings": {
112+
"Octopus.ControlType": "MultiLineText"
113+
}
114+
}
115+
],
116+
"StepPackageId": "Octopus.AzurePowerShell",
117+
"$Meta": {
118+
"ExportedAt": "2026-02-07T00:07:05.054Z",
119+
"OctopusVersion": "2025.4.10395",
120+
"Type": "ActionTemplate"
121+
},
122+
"LastModifiedBy": "twerthi",
123+
"Category": "azure"
124+
}

0 commit comments

Comments
 (0)