Trusted Microsoft services should be enabled for Storage Account access to ensure that Azure resources such as Azure Backup, Azure Monitor, and others can securely interact with the Storage Account without exposing it more broadly. When the bypass attribute in azurerm_storage_account or azurerm_storage_account_network_rules does not include "AzureServices", essential Azure services may be denied access, or administrators may compensate by setting overly permissive network rules, increasing the attack surface. To ensure a secure configuration, the storage account should be configured as follows:
Failing to enable trusted Microsoft services can hinder platform functionality or lead to weaker network restrictions that unnecessarily expose the storage account to risk.
resource"azurerm_resource_group""test"{name="test-rg"location="eastus"}resource"azurerm_resource_group""example"{name="example-rg"location="eastus"}resource"azurerm_virtual_network""test"{name="test-vnet"address_space=["10.0.0.0/16"]location=azurerm_resource_group.test.locationresource_group_name=azurerm_resource_group.test.name}resource"azurerm_subnet""test"{name="test-subnet"resource_group_name=azurerm_resource_group.test.namevirtual_network_name=azurerm_virtual_network.test.nameaddress_prefixes=["10.0.1.0/24"]}resource"azurerm_virtual_network""example"{name="example-vnet"address_space=["10.1.0.0/16"]location=azurerm_resource_group.example.locationresource_group_name=azurerm_resource_group.example.name}resource"azurerm_subnet""example"{name="example-subnet"resource_group_name=azurerm_resource_group.example.namevirtual_network_name=azurerm_virtual_network.example.nameaddress_prefixes=["10.1.1.0/24"]}resource"azurerm_storage_account""test"{name="storagetestaccount"resource_group_name=azurerm_resource_group.test.namelocation=azurerm_resource_group.test.locationaccount_tier="Standard"account_replication_type="LRS"}resource"azurerm_storage_account_network_rules""positive1"{storage_account_id=azurerm_storage_account.test.iddefault_action="Allow"ip_rules=["127.0.0.1"]virtual_network_subnet_ids=[azurerm_subnet.test.id]bypass=["Metrics"]}resource"azurerm_storage_account""positive2"{name="storageaccountname"resource_group_name=azurerm_resource_group.example.namelocation=azurerm_resource_group.example.locationaccount_tier="Standard"account_replication_type="LRS"network_rules{default_action="Deny"bypass=["None"]ip_rules=["100.0.0.1"]virtual_network_subnet_ids=[azurerm_subnet.example.id]}tags={environment="staging"}}# Not targeted by any azurerm_storage_account_network_rules resource and has
# no inline network_rules block - must still be flagged even though a
# separate network-rules resource exists elsewhere in this document.
resource"azurerm_storage_account""positive3"{name="storageaccountpositive3"resource_group_name=azurerm_resource_group.example.namelocation=azurerm_resource_group.example.locationaccount_tier="Standard"account_replication_type="LRS"}
1
2
rulesets:- Terraform / Azure # Rules to enforce / Azure.
Request a personalized demo
Get Started with Datadog
Ask AI
AI-generated responses may be inaccurate. Verify important info.