Skip to content

Commit 73b4efb

Browse files
authored
Add option to skip package deployment (#31)
1 parent e62d2a7 commit 73b4efb

5 files changed

Lines changed: 92 additions & 0 deletions

File tree

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,24 @@ Runnable examples are available under [`examples`](examples):
156156

157157
### Operations
158158

159+
- Azure Functions Flex Consumption currently returns a corrupted OneDeploy ARM
160+
response, causing `azapi_resource.deployment` to fail even when the package is
161+
deployed successfully. Set `skip_package_deployment = true` to omit OneDeploy
162+
from Terraform and deploy the package out-of-band. `export_api_key` must remain
163+
`false` in this mode because Terraform cannot order the host key lookup after
164+
an external deployment.
165+
- The following command shows how to deploy the package after Terraform creates
166+
the Function App. Replace the placeholders with the module output and desired
167+
Acmebot version. The Azure CLI may still report the response parsing error;
168+
verify the resulting deployment separately until the Azure platform issue is
169+
resolved.
170+
171+
```bash
172+
az rest --method PUT \
173+
--url "https://management.azure.com<function-app-resource-id>/extensions/onedeploy?api-version=2025-03-01" \
174+
--body '{"properties":{"type":"zip","packageUri":"https://github.com/polymind-inc/acmebot/releases/download/v<version>/acmebot.zip","remoteBuild":false}}'
175+
```
176+
159177
- Set `log_analytics_workspace.resource_id` and/or
160178
`application_insights.resource_id` to reuse existing monitoring resources.
161179
- Child resources inherit `var.tags` by default and support child-specific tag
@@ -715,6 +733,14 @@ object({
715733

716734
Default: `{}`
717735

736+
### <a name="input_skip_package_deployment"></a> [skip\_package\_deployment](#input\_skip\_package\_deployment)
737+
738+
Description: Whether to skip deploying the Acmebot package through OneDeploy. When true, the package must be deployed out-of-band and export\_api\_key must be false.
739+
740+
Type: `bool`
741+
742+
Default: `false`
743+
718744
### <a name="input_storage_account"></a> [storage\_account](#input\_storage\_account)
719745

720746
Description: Controls the Storage Account used by the Function App deployment package.

_header.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,24 @@ Runnable examples are available under [`examples`](examples):
155155

156156
### Operations
157157

158+
- Azure Functions Flex Consumption currently returns a corrupted OneDeploy ARM
159+
response, causing `azapi_resource.deployment` to fail even when the package is
160+
deployed successfully. Set `skip_package_deployment = true` to omit OneDeploy
161+
from Terraform and deploy the package out-of-band. `export_api_key` must remain
162+
`false` in this mode because Terraform cannot order the host key lookup after
163+
an external deployment.
164+
- The following command shows how to deploy the package after Terraform creates
165+
the Function App. Replace the placeholders with the module output and desired
166+
Acmebot version. The Azure CLI may still report the response parsing error;
167+
verify the resulting deployment separately until the Azure platform issue is
168+
resolved.
169+
170+
```bash
171+
az rest --method PUT \
172+
--url "https://management.azure.com<function-app-resource-id>/extensions/onedeploy?api-version=2025-03-01" \
173+
--body '{"properties":{"type":"zip","packageUri":"https://github.com/polymind-inc/acmebot/releases/download/v<version>/acmebot.zip","remoteBuild":false}}'
174+
```
175+
158176
- Set `log_analytics_workspace.resource_id` and/or
159177
`application_insights.resource_id` to reuse existing monitoring resources.
160178
- Child resources inherit `var.tags` by default and support child-specific tag

main.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,14 @@ resource "azapi_resource" "storage_account_function_app_role_assignment" {
204204
response_export_values = []
205205
}
206206

207+
moved {
208+
from = azapi_resource.deployment
209+
to = azapi_resource.deployment[0]
210+
}
211+
207212
resource "azapi_resource" "deployment" {
213+
count = var.skip_package_deployment ? 0 : 1
214+
208215
name = "onedeploy"
209216
parent_id = module.this.resource_id
210217
type = "Microsoft.Web/sites/extensions@2025-03-01"

tests/unit/variables.tftest.hcl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,35 @@ variables {
101101

102102
run "default_inputs_plan_successfully" {
103103
command = plan
104+
105+
assert {
106+
condition = length(azapi_resource.deployment) == 1
107+
error_message = "The Acmebot package should be deployed by default."
108+
}
109+
}
110+
111+
run "package_deployment_can_be_skipped" {
112+
command = plan
113+
114+
variables {
115+
skip_package_deployment = true
116+
}
117+
118+
assert {
119+
condition = length(azapi_resource.deployment) == 0
120+
error_message = "The OneDeploy resource should not be planned when package deployment is skipped."
121+
}
122+
}
123+
124+
run "skipped_package_deployment_cannot_export_api_key" {
125+
command = plan
126+
127+
variables {
128+
skip_package_deployment = true
129+
export_api_key = true
130+
}
131+
132+
expect_failures = [var.skip_package_deployment]
104133
}
105134

106135
run "sovereign_environment_plan_successfully" {

variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,18 @@ variable "instance_memory_in_mb" {
867867
}
868868
}
869869

870+
variable "skip_package_deployment" {
871+
type = bool
872+
description = "Whether to skip deploying the Acmebot package through OneDeploy. When true, the package must be deployed out-of-band and export_api_key must be false."
873+
default = false
874+
nullable = false
875+
876+
validation {
877+
condition = !var.skip_package_deployment || !var.export_api_key
878+
error_message = "export_api_key must be false when skip_package_deployment is true because Terraform cannot order the host key lookup after an out-of-band package deployment."
879+
}
880+
}
881+
870882
variable "export_api_key" {
871883
type = bool
872884
description = "Whether to read and export the default function host key as output."

0 commit comments

Comments
 (0)