1

When I try to create a workflow in my already existing Logic App (Standard). I use 1 file (main.tf) for deployment, I know it's not best practice but it is for testing purposes.

This is my main.tf:

resource "azurerm_resource_group" "tftest" {
name     = "Terraform-resourcegroup-klant1"
location = "West Europe"
}

data "azurerm_resource_group" "serviceBusRG" {
name = "Service_bus_integration"
}

data "azurerm_servicebus_namespace" "customerServiceBus" {
name = "CustomerIntegrationASB"
resource_group_name = data.azurerm_resource_group.serviceBusRG.name
}

data "azurerm_managed_api" "apitf" {
name     = "servicebus"
location = azurerm_resource_group.tftest.location
}

resource "azurerm_api_connection" "apiConncection" {
name                = "Servicebus-connection"
resource_group_name = azurerm_resource_group.tftest.name
managed_api_id      = data.azurerm_managed_api.apitf.id
display_name        = "API connection 1 test"

parameter_values = {
connectionString = data.azurerm_servicebus_namespace.customerServiceBus.default_primary_connection_string
}
}

resource "azurerm_servicebus_topic" "tenableTopic" {
name = "TenableTerraform"
namespace_id = data.azurerm_servicebus_namespace.customerServiceBus.id
max_size_in_megabytes = 1024
}

resource "azurerm_servicebus_subscription" "tenableSub" {
name = "Klant1"
topic_id = azurerm_servicebus_topic.tenableTopic.id
max_delivery_count = 1
}

resource "azurerm_servicebus_subscription_rule" "tenableFilter" {
name = "Klant1filter"
subscription_id = azurerm_servicebus_subscription.tenableSub.id
filter_type = "CorrelationFilter"

    correlation_filter {
    label = "Klant 1-naam"

}
}

resource "azurerm_storage_account" "storageAccountKlant1" {
name = "klant1storageaccount"
resource_group_name = azurerm_resource_group.tftest.name
location = azurerm_resource_group.tftest.location
account_tier = "Standard"
account_replication_type = "LRS"

}

resource "azurerm_service_plan" "appServicePlanKlant1" {
name = "AppServicePlanKlant1"
location = azurerm_resource_group.tftest.location
resource_group_name = azurerm_resource_group.tftest.name
os_type = "Windows"
sku_name = "WS1"
}

resource "azurerm_logic_app_standard" "logicAppKlant1" {
name = "LogicAppKlant1"
location = azurerm_resource_group.tftest.location
resource_group_name = azurerm_resource_group.tftest.name
app_service_plan_id = azurerm_service_plan.appServicePlanKlant1.id
storage_account_name = azurerm_storage_account.storageAccountKlant1.name
storage_account_access_key = azurerm_storage_account.storageAccountKlant1.primary_access_key

    app_settings = {
      "FUNCTIONS_WORKER_RUNTIME_VERSION" = "~4"
    }

}

resource "azurerm_resource_group_template_deployment" "workflowtje" {
name = "TemplateWorkflowKlant1"
resource_group_name = azurerm_resource_group.tftest.name
deployment_mode = "Complete"

template_content = file("/home/customer/vscode/terraform/logicappcomplete/jsons/readvulns.json")

parameters_content = jsonencode({
"logicAppName" = {
value = azurerm_logic_app_standard.logicAppKlant1.name
}
})
}

This .tf file contains the necessary resources my Logic App needs, such as its Resource Group, a unique Topic + Subscription on an existing Service Bus and a unique Storage Account.

As you can see, the bottom resourse is of type "azurerm_resource_group_template_deployment". This resource grabs the readvulns.json file, which contains the template for creating a workflow. This is the content of that readvulns.json file:

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "logicAppName": {
            "type": "string"
        }
    },
    "resources": [
        {
            "type": "Microsoft.Web/sites/workflows",
            "apiVersion": "2022-03-01",
            "name": "[concat(parameters('logicAppName'), '/testworkflow1')]",
            "location": "[resourceGroup().location]",
            "properties": {
                "definition": {
                    "$schema": "https://schema.management.azure.com/schemas/2016-06-01/workflowdefinition.json#",
                    "actions": {
                        "Response": {
                            "inputs": {
                                "statusCode": 200,
                                "body": {
                                    "message": "Hello from Logic App!"
                                }
                            },
                            "runAfter": {},
                            "type": "Response"
                        }
                    },
                    "triggers": {
                        "manualTrigger": {
                            "inputs": {},
                            "kind": "Http",
                            "type": "Request"
                        }
                    },
                    "parameters": {},
                    "outputs": {}
                }
            }
        }
    ]
}

After making sure the readvulns.json file is found by the main.tf file, I run the following commands for plan + apply:

**terraform plan -out "completetest"**
**terraform apply "completetest"**
  • This is the output from terraform plan -out "completetest"
data.azurerm_resource_group.serviceBusRG: Reading...
azurerm_resource_group.tftest: Refreshing state... \[id=/subscriptions/1111111111-1111111111111111111/resourceGroups/Terraform-resourcegroup-klant1\]
data.azurerm_resource_group.serviceBusRG: Read complete after 0s \[id=/subscriptions/1111111111-1111111111111111111/resourceGroups/Service_bus_integration\]
azurerm_service_plan.appServicePlanKlant1: Refreshing state... \[id=/subscriptions/1111111111-1111111111111111111/resourceGroups/Terraform-resourcegroup-klant1/providers/Microsoft.Web/serverFarms/AppServicePlanKlant1\]
data.azurerm_managed_api.apitf: Reading...
data.azurerm_servicebus_namespace.customerServiceBus: Reading...
azurerm_storage_account.storageAccountKlant1: Refreshing state... \[id=/subscriptions/1111111111-1111111111111111111/resourceGroups/Terraform-resourcegroup-klant1/providers/Microsoft.Storage/storageAccounts/klant1storageaccount\]
data.azurerm_managed_api.apitf: Read complete after 0s \[id=/subscriptions/1111111111-1111111111111111111/providers/Microsoft.Web/locations/westeurope/managedApis/servicebus\]
data.azurerm_servicebus_namespace.customerServiceBus: Read complete after 1s \[id=/subscriptions/1111111111-1111111111111111111/resourceGroups/Service_bus_integration/providers/Microsoft.ServiceBus/namespaces/CustomerIntegrationASB\]
azurerm_api_connection.apiConncection: Refreshing state... \[id=/subscriptions/1111111111-1111111111111111111/resourceGroups/Terraform-resourcegroup-klant1/providers/Microsoft.Web/connections/Servicebus-connection\]
azurerm_servicebus_topic.tenableTopic: Refreshing state... \[id=/subscriptions/1111111111-1111111111111111111/resourceGroups/Service_bus_integration/providers/Microsoft.ServiceBus/namespaces/CustomerIntegrationASB/topics/TenableTerraform\]
azurerm_servicebus_subscription.tenableSub: Refreshing state... \[id=/subscriptions/1111111111-1111111111111111111/resourceGroups/Service_bus_integration/providers/Microsoft.ServiceBus/namespaces/CustomerIntegrationASB/topics/TenableTerraform/subscriptions/Klant1\]
azurerm_servicebus_subscription_rule.tenableFilter: Refreshing state... \[id=/subscriptions/1111111111-1111111111111111111/resourceGroups/Service_bus_integration/providers/Microsoft.ServiceBus/namespaces/CustomerIntegrationASB/topics/TenableTerraform/subscriptions/Klant1/rules/Klant1filter\]
azurerm_logic_app_standard.logicAppKlant1: Refreshing state... \[id=/subscriptions/1111111111-1111111111111111111/resourceGroups/Terraform-resourcegroup-klant1/providers/Microsoft.Web/sites/LogicAppKlant1\]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:

+ create
  \-/+ destroy and then create replacement

Terraform will perform the following actions:

# azurerm_api_connection.apiConncection must be replaced

\-/+ resource "azurerm_api_connection" "apiConncection" {
\~ id                  = "/subscriptions/f2f014c7-0bad-40c3-ace9-dac60d3479b5/resourceGroups/Terraform-resourcegroup-klant1/providers/Microsoft.Web/connections/Servicebus-connection" -\> (known after apply)
name                = "Servicebus-connection"
\~ parameter_values    = { # forces replacement
\+ "connectionString" = (sensitive value)
}
tags                = {
"Hello" = "World"
}
\# (3 unchanged attributes hidden)
}

# azurerm_resource_group_template_deployment.workflowtje will be created

+ resource "azurerm_resource_group_template_deployment" "workflowtje" {
  + deployment_mode     = "Complete"
  + id                  = (known after apply)
  + name                = "TemplateWorkflowKlant1"
  + output_content      = (known after apply)
  + parameters_content  = jsonencode(
    {
    \+ logicAppName = {
    \+ value = "LogicAppKlant1"
    }
    }
    )
  + resource_group_name = "Terraform-resourcegroup-klant1"
  + template_content    = jsonencode(
    {
    \+ "$schema"      = "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#"
    \+ contentVersion = "1.0.0.0"
    \+ parameters     = {
    \+ logicAppName = {
    \+ type = "string"
    }
    }
    \+ resources      = \[
    \+ {
    \+ apiVersion = "2022-03-01"
    \+ location   = "\[resourceGroup().location\]"
    \+ name       = "\[concat(parameters('logicAppName'), '/testworkflow1')\]"
    \+ properties = {
    \+ definition = {
    \+ "$schema"  = "https://schema.management.azure.com/schemas/2016-06-01/workflowdefinition.json#"
    \+ actions    = {
    \+ Response = {
    \+ inputs   = {
    \+ body       = {
    \+ message = "Hello from Logic App!"
    }
    \+ statusCode = 200
    }
    \+ runAfter = {}
    \+ type     = "Response"
    }
    }
    \+ outputs    = {}
    \+ parameters = {}
    \+ triggers   = {
    \+ manualTrigger = {
    \+ inputs = {}
    \+ kind   = "Http"
    \+ type   = "Request"
    }
    }
    }
    }
    \+ type       = "Microsoft.Web/sites/workflows"
    },
    \]
    }
    )
    }

Plan: 2 to add, 0 to change, 1 to destroy.\
  • This is the output from terraform plan "completetest":

azurerm_api_connection.apiConncection: Destroying... [id=/subscriptions/1111111111-1111111111111111111/resourceGroups/Terraform-resourcegroup-klant1/providers/Microsoft.Web/connections/Servicebus-connection] azurerm_resource_group_template_deployment.workflowtje: Creating... azurerm_api_connection.apiConncection: Destruction complete after 2s azurerm_api_connection.apiConncection: Creating... azurerm_api_connection.apiConncection: Creation complete after 2s [id=/subscriptions/1111111111-1111111111111111111/resourceGroups/Terraform-resourcegroup-klant1/providers/Microsoft.Web/connections/Servicebus-connection] azurerm_resource_group_template_deployment.workflowtje: Still creating... [10s elapsed] azurerm_resource_group_template_deployment.workflowtje: Still creating... [20s elapsed] azurerm_resource_group_template_deployment.workflowtje: Still creating... [30s elapsed] ╷ │ Error: waiting for creation of Template Deployment "TemplateWorkflowKlant1" (Resource Group "Terraform-resourcegroup-klant1"): Code="DeploymentFailed" Message="At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-deployment-operations for usage details." Details=[{"code":"MethodNotAllowed","message":"{\r\n \"Message\": \"The requested resource does not support http method 'PUT'.\"\r\n}"}] │ │ with azurerm_resource_group_template_deployment.workflowtje, │ on main.tf line 99, in resource "azurerm_resource_group_template_deployment" "workflowtje": │ 99: resource "azurerm_resource_group_template_deployment" "workflowtje" {

As you can see, the error I get is: The requested resource does not support http method 'PUT'. Everything is created successfully, except for the workflow in my existing Logic App (Standard). Am I doing something wrong here?

I already tried to create other types of resources in readvulns.json but no success.

3
  • 1
    Are you using the latest terraform release. @Denver Commented Oct 17, 2024 at 4:49
  • 1
    Hi Jahnavi, this is the output from "terraform --version": Terraform v1.9.7 on linux_amd64 + provider registry.terraform.io/hashicorp/azurerm v4.5.0 + provider registry.terraform.io/hashicorp/random v3.6.3 Commented Oct 17, 2024 at 8:17
  • Is the given approach worked for you! @Denver Commented Oct 29, 2024 at 5:55

1 Answer 1

0

The requested resource does not support http method 'PUT'.

The error occurs due to the conflict in the template resource deployment block within the workflow.json file. After verifying it, I found that the issue is with the input type of the workflow. It should be Microsoft.Logic/workflows rather thanMicrosoft.Web/sites/workflows.

Modify it to Microsoft.Logic/workflows in the workflow.json file with the corresponding API version as shown below.

"type": "Microsoft.Logic/workflows" and "apiVersion": "2019-05-01"

Below is the Workflow.json file after modifications:

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "logicAppName": {
            "type": "string",
            "defaultValue": "xxxxx"
        }
    },
    "resources": [
        {
            "type": "Microsoft.Logic/workflows",
            "apiVersion": "2019-05-01",
            "name": "[parameters('logicAppName')]",
            "location": "[resourceGroup().location]",
            "properties": {
                "definition": {
                    "$schema": "https://schema.management.azure.com/schemas/2016-06-01/workflowdefinition.json#",
                    "actions": {
                        "Response": {
                            "inputs": {
                                "statusCode": 200,
                                "body": {
                                    "message": "Hello from Logic App!"
                                }
                            },
                            "runAfter": {},
                            "type": "Response"
                        }
                    },
                    "triggers": {
                        "manualTrigger": {
                            "inputs": {},
                            "kind": "Http",
                            "type": "Request"
                        }
                    },
                    "parameters": {},
                    "outputs": {}
                }
            }
        }
    ]
}

Complete Terraform code:

provider "azurerm" {
  features {}
  subscription_id = "xxxx"
}

data "azurerm_resource_group" "serviceBusRG" {
name = "postres"
}

data "azurerm_servicebus_namespace" "customerServiceBus" {
name = "newposp"
resource_group_name = data.azurerm_resource_group.serviceBusRG.name
}

data "azurerm_managed_api" "example" {
  name     = "servicebus"
  location = data.azurerm_resource_group.serviceBusRG.location
}

resource "azurerm_api_connection" "apiConncection" {
name                = "Servicebus-connection"
resource_group_name = data.azurerm_resource_group.serviceBusRG.name
managed_api_id      = data.azurerm_managed_api.apitf.id
display_name        = "API connection 1 test"

parameter_values = {
connectionString = data.azurerm_servicebus_namespace.customerServiceBus.default_primary_connection_string
}
}

resource "azurerm_servicebus_topic" "tenableTopic" {
name = "TenableTerraform"
namespace_id = data.azurerm_servicebus_namespace.customerServiceBus.id
max_size_in_megabytes = 1024
}

resource "azurerm_servicebus_subscription" "tenableSub" {
name = "Klant1"
topic_id = azurerm_servicebus_topic.tenableTopic.id
max_delivery_count = 1
}

resource "azurerm_servicebus_subscription_rule" "tenableFilter" {
name = "Klant1filter"
subscription_id = azurerm_servicebus_subscription.tenableSub.id
filter_type = "CorrelationFilter"

    correlation_filter {
    label = "Klant 1-naam"

}
}

resource "azurerm_storage_account" "storageAccountKlant1" {
name = "klant1storageaccount"
resource_group_name = data.azurerm_resource_group.serviceBusRG.name
location = data.azurerm_resource_group.serviceBusRG.location
account_tier = "Standard"
account_replication_type = "LRS"

}

resource "azurerm_service_plan" "appServicePlanKlant1" {
name = "AppServicePlanKlant1"
location = data.azurerm_resource_group.serviceBusRG.location
resource_group_name = data.azurerm_resource_group.serviceBusRG.name
os_type = "Windows"
sku_name = "WS1"
}

resource "azurerm_logic_app_standard" "logicAppKlant1" {
name = "LogicAppKlant1"
location = data.azurerm_resource_group.serviceBusRG.location
resource_group_name = data.azurerm_resource_group.serviceBusRG.name
app_service_plan_id = azurerm_service_plan.appServicePlanKlant1.id
storage_account_name = azurerm_storage_account.storageAccountKlant1.name
storage_account_access_key = azurerm_storage_account.storageAccountKlant1.primary_access_key

    app_settings = {
      "FUNCTIONS_WORKER_RUNTIME_VERSION" = "~4"
    }

}

resource "azurerm_resource_group_template_deployment" "workflowtje" {
name = "TemplateWorkflowKlant1"
resource_group_name = data.azurerm_resource_group.serviceBusRG.name
deployment_mode = "Complete"

template_content = file("/home/madugula/workflow.json")

parameters_content = jsonencode({
"logicAppName" = {
value = azurerm_logic_app_standard.logicAppKlant1.name
}
})
}

Output:

enter image description here

Deployed successfully:

enter image description here

enter image description here

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.