hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.53k stars 4.6k forks source link

azurerm_analysis_services_server blob storage container not saving in backup configuration #17178

Open KezHalls opened 2 years ago

KezHalls commented 2 years ago

Is there an existing issue for this?

Community Note

Terraform Version

1.2.2

AzureRM Provider Version

0.14

Affected Resource(s)/Data Source(s)

azurerm_analysis_services_server

Terraform Configuration Files

resource "azurerm_storage_account" "storage_account" {
    name                        = var.storage_account_name
    resource_group_name         = var.resource_group_name
    location                    = var.location
    account_replication_type    = var.storage_account_replication_type
    account_tier                = var.storage_account_tier
    access_tier                 = "Cool"
    account_kind                = "StorageV2"
    min_tls_version             = var.storage_account_tls
    tags                        = var.tags

    # identity {
    #     type                    = "UserAssigned"
    # }
}

#******************************************************************************
# Container
#******************************************************************************
resource "azurerm_storage_container" "container_analysis_services" {
    name                        = var.container_name
    storage_account_name        = azurerm_storage_account.storage_account.name
    container_access_type       = "private"
}

#******************************************************************************
# SAS token
#******************************************************************************
data "azurerm_storage_account_blob_container_sas" "account_sas" {
    connection_string           = azurerm_storage_account.storage_account.primary_connection_string
    container_name              = azurerm_storage_container.container_analysis_services.name
    https_only                  = true

    start                       = "2019-12-26"
    expiry                      = "2025-01-01"

    permissions {
        read                    = true
        write                   = true
        delete                  = true
        list                    = true
        add                     = true
        create                  = true
    }

    cache_control               = "max-age=5"
    content_disposition         = "inline"
    content_encoding            = "deflate"
    content_language            = "en-US"
    content_type                = "application/json"
}

resource "azurerm_analysis_services_server" "analysis_services_server" {
    name                        = var.aas_name 
    sku                         = var.aas_sku
    admin_users                 = var.aas_admins
    location                    = var.location
    resource_group_name         = var.resource_group_name
    tags                        = var.tags
    querypool_connection_mode   = "All"
    enable_power_bi_service     = true
    backup_blob_container_uri   = "https://${var.storage_account_name}.blob.core.windows.net/${var.container_name}/${var.sas_token}"

    dynamic "ipv4_firewall_rule" {
      for_each = var.netskope_ip_address_range

      content {
        name        = ipv4_firewall_rule.value["name"]
        range_start = ipv4_firewall_rule.value["range_min"]
        range_end   = ipv4_firewall_rule.value["range_max"]
      }
    }

}

Debug Output/Panic Output

private info

Expected Behaviour

the "Backups --> Backup Storage Settings Should have the storage account and container name saved ie: backupstorageacname\containername

Actual Behaviour

it only saves the storage account name with no reference to the container name

backupstorageacname\

Steps to Reproduce

apply code above

Important Factoids

No response

References

16610 is similar but they are getting an error. I don't get any errors running this

sinbai commented 2 years ago

@KezHalls thank you for opening this issue here. Unfortunately, I could not repro the issue using the terraform config below. Could you repro with it?

terraform {
required_providers {
    azurerm = {
      source = "hashicorp/azurerm"
      version = "3.8.0"
    }
  }
}

provider "azurerm" {
   features {
 }
}

resource "azurerm_resource_group" "test" {
  name     = "RG-analysis-sample"
  location = "eastus"
}

resource "azurerm_storage_account" "test" {
  name                     = "testassaccsample"
  resource_group_name      = azurerm_resource_group.test.name
  location                 = azurerm_resource_group.test.location
  account_kind             = "StorageV2"
  account_tier             = "Standard"
  account_replication_type = "LRS"
}

resource "azurerm_storage_container" "test" {
  name                  = "assbackup"
  storage_account_name  = azurerm_storage_account.test.name
  container_access_type = "private"
}

data "azurerm_storage_account_blob_container_sas" "test" {
  connection_string           = azurerm_storage_account.test.primary_connection_string
  container_name              = azurerm_storage_container.test.name
  https_only                  = true

  start                       = "2019-12-26"
  expiry                      = "2025-01-01"

  permissions {
        read                    = true
        write                   = true
        delete                  = true
        list                    = true
        add                     = true
        create                  = true
  }

  cache_control               = "max-age=5"
  content_disposition         = "inline"
  content_encoding            = "deflate"
  content_language            = "en-US"
  content_type                = "application/json"
}

resource "azurerm_analysis_services_server" "test" {
  name                = "assservicesample"
  location            = azurerm_resource_group.test.location
  resource_group_name = azurerm_resource_group.test.name
  sku                 = "B1"
  querypool_connection_mode   = "All"
  enable_power_bi_service     = true
  backup_blob_container_uri = "${azurerm_storage_account.test.primary_blob_endpoint}${azurerm_storage_container.test.name}${data.azurerm_storage_account_blob_container_sas.test.sas}"
}

After running terraform apply, the container name is saved as follows: image

KezHalls commented 2 years ago

No success here. I changed my storage to use same config as you but didn't work.

resource "azurerm_storage_account" "storage_account" {
    name                        = var.storage_account_name
    resource_group_name         = var.resource_group_name
    location                    = var.location
    account_replication_type    = "LRS" #var.storage_account_replication_type
    account_tier                = "Standard" #var.storage_account_tier
    #access_tier                 = "Cool"
    account_kind                = "StorageV2"
    #min_tls_version             = var.storage_account_tls
    tags                        = merge(var.tags, tomap(var.tag_description))
    #allow_nested_items_to_be_public = false

    network_rules {
        default_action             = "Allow"
        #ip_rules                   = ["100.0.0.1"]
        #virtual_network_subnet_ids = [azurerm_subnet.example.id]
    }
    identity {
         type         = "UserAssigned"
         identity_ids = [var.user_managed_identity_id] #azurerm_user_assigned_identity.uai.id]
    }
}
resource "azurerm_storage_container" "container_analysis_services" {
    name                        = var.as_backup_container_name
    storage_account_name        = azurerm_storage_account.storage_account.name
    container_access_type       = "private"

    depends_on                  = [azurerm_storage_account.storage_account]
}
data "azurerm_storage_account_blob_container_sas" "account_sas" {
    connection_string           = azurerm_storage_account.storage_account.primary_connection_string
    container_name              = azurerm_storage_container.container_analysis_services.name
    https_only                  = true

    start                       = "2019-12-26"
    expiry                      = "2025-01-01"

    permissions {
        read                    = true
        write                   = true
        delete                  = true
        list                    = true
        add                     = true
        create                  = true
    }

    cache_control               = "max-age=5"
    content_disposition         = "inline"
    content_encoding            = "deflate"
    content_language            = "en-US"
    content_type                = "application/json"
}
resource "azurerm_analysis_services_server" "this" {
    name                        = var.as_name 
    sku                         = var.as_sku
    admin_users                 = var.as_admins
    location                    = var.location
    resource_group_name         = var.resource_group_name
    tags                        = merge(var.tags, var.tag_description)
    querypool_connection_mode   = "All"
    enable_power_bi_service     = true
    backup_blob_container_uri   = "https://${var.storage_account_name}.blob.core.windows.net/${var.as_backup_container_name}/${var.sas_token}"

`

KezHalls commented 11 months ago

I still have this issue. there was never any further feedback.