Closed jasric89 closed 2 years ago
Please can I get an update on this bug?
I think I'm facing a similar issue with my Linux container on AppSvc. I'm now trying Log Analytics (via Diagnostic Settings instead) but I'm curious to know if this should work or not.
resource "azurerm_app_service_plan" "deployment" {
name = random_pet.deployment.id
location = azurerm_resource_group.deployment.location
resource_group_name = azurerm_resource_group.deployment.name
kind = "Linux"
reserved = true
sku {
tier = "Basic"
size = "B1"
}
}
resource "azurerm_app_service" "deployment" {
name = random_pet.deployment.id
location = azurerm_resource_group.deployment.location
resource_group_name = azurerm_resource_group.deployment.name
app_service_plan_id = azurerm_app_service_plan.deployment.id
identity {
type = "SystemAssigned"
}
logs {
application_logs {
azure_blob_storage {
level = "Verbose"
retention_in_days = 7
sas_url = format("https://${azurerm_storage_account.deployment.name}.blob.core.windows.net/${azurerm_storage_container.applicationlogs.name}%s", data.azurerm_storage_account_blob_container_sas.applicationlogs.sas)
#data.azurerm_storage_account_blob_container_sas.applicationlogs.sas
}
}
http_logs {
azure_blob_storage {
retention_in_days = 7
sas_url = format("https://${azurerm_storage_account.deployment.name}.blob.core.windows.net/${azurerm_storage_container.httplogs.name}%s", data.azurerm_storage_account_blob_container_sas.httplogs.sas)
}
}
}
site_config {
acr_use_managed_identity_credentials = true
linux_fx_version = "DOCKER|${azurerm_container_registry.deployment.name}.azurecr.io/frontend/frontend:latest"
}
}
resource "azurerm_role_assignment" "acrpull_role" {
scope = azurerm_container_registry.deployment.id
role_definition_name = "AcrPull"
principal_id = azurerm_app_service.deployment.identity.0.principal_id
}
resource "azurerm_storage_container" "applicationlogs" {
name = "applicationlogs"
storage_account_name = azurerm_storage_account.deployment.name
container_access_type = "private"
}
data "azurerm_storage_account_blob_container_sas" "applicationlogs" {
connection_string = azurerm_storage_account.deployment.primary_connection_string
container_name = azurerm_storage_container.applicationlogs.name
https_only = true
start = timestamp()
expiry = timeadd(timestamp(), "168h")
permissions {
read = true
add = true
create = false
write = false
delete = true
list = true
}
}
This results in a, at a first glance, viable Microsot.Web/sites/config
resource:
{
"type": "Microsoft.Web/sites/config",
"apiVersion": "2021-02-01",
"name": "[concat(parameters('sites_becomingporpoise_name'), '/web')]",
"location": "West Europe",
"dependsOn": [
"[resourceId('Microsoft.Web/sites', parameters('sites_becomingporpoise_name'))]"
],
"properties": {
"numberOfWorkers": 1,
"defaultDocuments": [],
"netFrameworkVersion": "v4.0",
"linuxFxVersion": "DOCKER|becomingporpoise.azurecr.io/frontend/frontend:latest",
"requestTracingEnabled": false,
"remoteDebuggingEnabled": false,
"remoteDebuggingVersion": "VS2019",
"httpLoggingEnabled": true,
"acrUseManagedIdentityCreds": true,
"logsDirectorySizeLimit": 35,
"detailedErrorLoggingEnabled": false,
"publishingUsername": "$becomingporpoise",
"scmType": "None",
"use32BitWorkerProcess": false,
"webSocketsEnabled": false,
"alwaysOn": false,
"managedPipelineMode": "Integrated",
"virtualApplications": [
{
"virtualPath": "/",
"physicalPath": "site\\wwwroot",
"preloadEnabled": false
}
],
"loadBalancing": "LeastRequests",
"experiments": {
"rampUpRules": []
},
"autoHealEnabled": false,
"vnetRouteAllEnabled": false,
"vnetPrivatePortsCount": 0,
"cors": {
"allowedOrigins": [],
"supportCredentials": false
},
"localMySqlEnabled": false,
"managedServiceIdentityId": 16213,
"ipSecurityRestrictions": [
{
"ipAddress": "Any",
"action": "Allow",
"priority": 1,
"name": "Allow all",
"description": "Allow all access"
}
],
"scmIpSecurityRestrictions": [
{
"ipAddress": "Any",
"action": "Allow",
"priority": 1,
"name": "Allow all",
"description": "Allow all access"
}
],
"scmIpSecurityRestrictionsUseMain": false,
"http20Enabled": false,
"minTlsVersion": "1.2",
"scmMinTlsVersion": "1.0",
"ftpsState": "AllAllowed",
"preWarmedInstanceCount": 0,
"functionAppScaleLimit": 0,
"functionsRuntimeScaleMonitoringEnabled": false,
"minimumElasticInstanceCount": 0,
"azureStorageAccounts": {
"becomingporpoise": {
"type": "AzureBlob",
"accountName": "becomingporpoise",
"shareName": "becomingporpoise"
}
}
}
},
The result in the portal looks like this - http_logs
and application_logs
are pointing to two different containers in the same storage account - the hcl snipped above contains only one container/sas definition.
But, my blob storage container remains empty - even after days:
@madsd do you know if this is supposed to work?
Hi, no - I am not deep in the monitoring and diagnostics. Does it work if you configure it through portal or CLI, and can you see a delta between the raw ARM configuration if configured through TF?
Can we have an update on this please?
The azurerm_app_service
resource has been superseded in v3.0 of the Azure Provider and is now feature-frozen to maintain compatibility - as such you'll need to migrate to those new resources instead: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/guides/3.0-upgrade-guide#new-resources-and-data-sources-for-app-service which I believe should work for you here.
If the new resources don't work for you then please let us know in a new issue and we can take another look, but since the older azurerm_app_service
resource has been superseded I'm going to close this issue for the moment.
Thanks!
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Community Note
Terraform (and AzureRM Provider) Version
Terraform v1.0.7 on linux_amd64
Affected Resource(s)
azurerm_app_service
azurerm_storage_account
azurerm_storage_container
Terraform Configuration Files
Debug Output
Panic Output
Expected Behaviour
Terraform App Service should write to storage account.
Actual Behaviour
Errors and doesn't write to storage account. I believe this may be a bug when specifying Storage Account Name in Web App Settings.
I first pointed to the storage account name but got the following error:
Upon researching more and according to this website: https://github.com/kumarvna/terraform-azurerm-app-service it should be the storage account identifier.
Error Message is the following:
Steps to Reproduce
terraform apply
Important Factoids
References
0000