cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Deploying the agent to Azure using ARM/Terraform

pjk2003
Visitor

Hi, I am trying to deploy the agent to an existing function app in azure using terraform and the guide at:

https://www.dynatrace.com/support/help/setup-and-configuration/setup-on-cloud-platforms/microsoft-az...

Has anyone got this working? It runs to plan but then fails in apply with this errot

 

resources.DeploymentsClient#Validate: Failure sending request: StatusCode=400 -- Original Error: Code="InvalidRequestContent" Message="The request content was invalid and could not be deserialized: 'Could not find member 'apiVersion' on object of type 'Template'. Path 'properties.template.apiVersion', line 1, position 132.'."

Here's my json

{
"apiVersion": "2016-08-01",
"name": "[parameters('resourceName')]",
"type": "Microsoft.Web/sites",
"properties": {
"name": "[parameters('resourceName')]",
"siteConfig": {
"alwaysOn": true,
"appSettings": [
{ "Name": "DT_TENANT", "Value": "[parameters('environmentID')]" },
{ "Name": "DT_API_TOKEN", "Value": "[parameters('APIToken')]" },
{ "Name": "DT_API_URL", "Value": "[parameters('APIUrl')]" },
{ "Name": "DT_SSL_MODE", "Value": "default" }
]
},
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('resourceName'))]"
},
"dependsOn": [
"[concat('Microsoft.Web/serverfarms/', parameters('resourceName'))]"
],
"location": "[parameters('location')]",
"resources": [
{
"apiVersion": "2016-08-01",
"name": "Dynatrace",
"type": "siteextensions",
"dependsOn": [
"[resourceId('Microsoft.Web/sites', parameters('resourceName'))]"
],
"properties": { }
}
]
}
4 REPLIES 4

pjk2003
Visitor

Ive been able to get it to deploy, with some new json, but its now killing the app and overwriting the settings.... I am specifying incremental mode.

 

New JSON

resource "azurerm_resource_group_template_deployment" "this" {
#count = lookup(var.env_deployent, terraform.workspace, false) == true ? 1 : 0 # *** Is this resource required? ***
name = "OneAgent-Deployment"
resource_group_name = var.resource_group
deployment_mode = "Incremental"



template_content = <<TEMPLATE
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {"siteName": {
"type": "string",
"metadata": {
"description": "Web app name where you would like to install extension."
}
},
"location": {
"type": "string",
"metadata": {
"description": "Region of your web app."
}
},
"environmentID": {
"type": "string",
"metadata": {
"description": "The environment ID."
}
},
"APIToken": {
"type": "string",
"metadata": {
"description": "The PaaS token."
}
},
"APIUrl": {
"type": "string",
"metadata": {
"description": "The server URL, if you want to configure an alternative communication endpoint."
}
},
"SSLMode": {
"type": "string",
"metadata": {
"description": "To automatically accept all self-signed TLS certificates, set the value to all."
},
"allowedValues": [
"default", "all"
],
"defaultValue": "default"
},
"networkZone": {
"type": "string",
"metadata": {
"description": "Your network zone. Set the value you want for your App Service instance. See network zones for more information."
},
"defaultValue": ""
}
},
"resources": [
{
"apiVersion": "2020-12-01",
"name": "[parameters('siteName')]",
"type": "Microsoft.Web/sites",
"properties": {
"name": "[parameters('siteName')]",
"siteConfig": {
"appSettings": [
{ "Name": "DT_TENANT", "Value": "[parameters('environmentID')]" },
{ "Name": "DT_API_TOKEN", "Value": "[parameters('APIToken')]" },
{ "Name": "DT_API_URL", "Value": "[parameters('APIUrl')]" },
{ "Name": "DT_SSL_MODE", "Value": "[parameters('SSLMode')]" },
{ "Name": "DT_NETWORK_ZONE", "Value": "[parameters('networkZone')]"}
]
}
},
"dependsOn": [],
"location": "[parameters('location')]",
"resources": [
{
"apiVersion": "2020-12-01",
"name": "Dynatrace",
"type": "siteextensions",
"dependsOn": [
"[resourceId('Microsoft.Web/sites/', parameters('siteName'))]"
]
}
]
}
],
"outputs": {}
}
TEMPLATE

danielD
Dynatrace Helper
Dynatrace Helper

Hello,

 

It looks like there's an option to install it via the Azure portal. Would you be able to try it that way and see if you're getting the same errors?

 

thanks

pjk2003
Visitor

It installs fine manually. 

pjk2003
Visitor

Was able to install it using a mixture of API calls in powershell called in a yaml pipeline.

Featured Posts