@Giovanni Fleres Here are the ARM and Bicep templates which worked for me in deploying the diagnostic settings of Container Apps Environment. Kindly try it from your end and revert if you have any questions.
Bicep Template:
param managedEnvironments_container_app_env_name string = 'container-app-e'
@description('description')
param workspaceId string = ''
@description('description')
param settingName string = 'diagtest'
resource managedEnvironments_container_app_env_name_resource 'Microsoft.App/managedEnvironments@2023-04-01-preview' = {
name: managedEnvironments_container_app_env_name
location: 'West US'
properties: {
appLogsConfiguration: {
destination: 'azure-monitor'
}
zoneRedundant: false
kedaConfiguration: {
}
daprConfiguration: {
}
customDomainConfiguration: {
}
peerAuthentication: {
mtls: {
enabled: false
}
}
}
}
resource setting 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = {
scope: managedEnvironments_container_app_env_name_resource
name: settingName
properties: {
workspaceId: workspaceId
logs: [
{
categoryGroup: 'AllLogs'
enabled: true
}
]
metrics: [
{
category: 'AllMetrics'
enabled: true
}
]
}
}
ARM Template:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"managedEnvironments_container_app_env_name": {
"defaultValue": "container-app-env",
"type": "String"
},
"workspaceId": {
"type": "string",
"defaultValue": "/subscriptions/xxxxxxxx-xxx-xxxx-xxxx-xxxx/resourcegroups/rg/providers/microsoft.operationalinsights/workspaces/xx",
"metadata": {
"description": "description"
}
},
"settingName": {
"type": "string",
"defaultValue":"diagtest",
"metadata": {
"description": "description"
}
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.App/managedEnvironments",
"apiVersion": "2023-04-01-preview",
"name": "[parameters('managedEnvironments_container_app_env_name')]",
"location": "West US",
"properties": {
"appLogsConfiguration": {
"destination": "azure-monitor"
},
"zoneRedundant": false,
"kedaConfiguration": {},
"daprConfiguration": {},
"customDomainConfiguration": {},
"peerAuthentication": {
"mtls": {
"enabled": false
}
}
}
},
{
"type": "Microsoft.Insights/diagnosticSettings",
"apiVersion": "2021-05-01-preview",
"name": "[parameters('settingName')]",
"scope": "[resourceId('Microsoft.App/managedEnvironments', parameters('managedEnvironments_container_app_env_name'))]",
"properties": {
"workspaceId": "[parameters('workspaceId')]",
"logs": [
{
"categorygroup":"allLogs",
"enabled": true
}
],
"metrics": [
{
"category": "AllMetrics",
"enabled": true
}
]
},
"dependsOn": [
"[resourceId('Microsoft.App/managedEnvironments', parameters('managedEnvironments_container_app_env_name'))]"
]
}
]
}