diff --git a/internal/services/storage/storage_account_resource.go b/internal/services/storage/storage_account_resource.go index 24abb26e9a9b..559842f7367b 100644 --- a/internal/services/storage/storage_account_resource.go +++ b/internal/services/storage/storage_account_resource.go @@ -647,6 +647,7 @@ func resourceStorageAccount() *pluginsdk.Resource { "share_properties": { Type: pluginsdk.TypeList, Optional: true, + // (@jackofallops) TODO - This should not be computed, however, this would be a breaking change with unknown implications for user data so needs to be addressed for 4.0 Computed: true, MaxItems: 1, Elem: &pluginsdk.Resource{ @@ -1344,17 +1345,22 @@ func resourceStorageAccountCreate(d *pluginsdk.ResourceData, meta interface{}) e fileServiceClient := meta.(*clients.Client).Storage.FileServicesClient shareProperties := expandShareProperties(val.([]interface{})) + // The API complains if any multichannel info is sent on non premium fileshares. Even if multichannel is set to false - if accountTier != string(storage.SkuTierPremium) { + if accountTier != string(storage.SkuTierPremium) && shareProperties.FileServicePropertiesProperties != nil && shareProperties.FileServicePropertiesProperties.ProtocolSettings != nil { // Error if the user has tried to enable multichannel on a standard tier storage account - if shareProperties.FileServicePropertiesProperties.ProtocolSettings.Smb.Multichannel != nil && shareProperties.FileServicePropertiesProperties.ProtocolSettings.Smb.Multichannel.Enabled != nil { - if *shareProperties.FileServicePropertiesProperties.ProtocolSettings.Smb.Multichannel.Enabled { - return fmt.Errorf("`multichannel_enabled` isn't supported for Standard tier Storage accounts") + smb := shareProperties.FileServicePropertiesProperties.ProtocolSettings.Smb + if smb != nil && smb.Multichannel != nil { + + if smb.Multichannel.Enabled != nil { + if *shareProperties.FileServicePropertiesProperties.ProtocolSettings.Smb.Multichannel.Enabled { + return fmt.Errorf("`multichannel_enabled` isn't supported for Standard tier Storage accounts") + } } - } - shareProperties.FileServicePropertiesProperties.ProtocolSettings.Smb.Multichannel = nil + shareProperties.FileServicePropertiesProperties.ProtocolSettings.Smb.Multichannel = nil + } } if _, err = fileServiceClient.SetServiceProperties(ctx, id.ResourceGroup, id.Name, shareProperties); err != nil { diff --git a/internal/services/storage/storage_account_resource_test.go b/internal/services/storage/storage_account_resource_test.go index 94379b540cd3..4c0fcb05da79 100644 --- a/internal/services/storage/storage_account_resource_test.go +++ b/internal/services/storage/storage_account_resource_test.go @@ -1350,6 +1350,21 @@ func TestAccStorageAccount_sasPolicy(t *testing.T) { }) } +func TestAccStorageAccount_emptyShareProperties(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_storage_account", "test") + r := StorageAccountResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.emptyShareProperties(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + func TestAccStorageAccount_isSftpEnabled(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_storage_account", "test") r := StorageAccountResource{} @@ -4131,6 +4146,31 @@ resource "azurerm_storage_account" "test" { `, data.RandomInteger, data.Locations.Primary, data.RandomString) } +func (r StorageAccountResource) emptyShareProperties(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-storage-%[1]d" + location = "%[2]s" +} + +resource "azurerm_storage_account" "test" { + name = "unlikely23exst2acct%[3]s" + resource_group_name = azurerm_resource_group.test.name + + location = azurerm_resource_group.test.location + account_tier = "Standard" + account_replication_type = "LRS" + account_kind = "StorageV2" + + share_properties {} +} +`, data.RandomInteger, data.Locations.Primary, data.RandomString) +} + func (r StorageAccountResource) isSftpEnabledTrue(data acceptance.TestData) string { return fmt.Sprintf(` provider "azurerm" {