@@ -10,23 +10,28 @@ resource "azurerm_storage_account" "durable_function_storage" {
1010 allow_nested_items_to_be_public = false
1111 infrastructure_encryption_enabled = true
1212
13- # Using this approach to allow access from the IP address running Terraform,
14- # this is required for the creation of the share below and run TF plan/apply
15- # in the future.
16- # You can manually disable public access completely after deploying this module,
17- # just remember to restore this rule before executing TF again.
18- public_network_access_enabled = true
13+ # The account is kept fully private: access is only possible through the
14+ # private endpoints below. The share is created via the azapi provider
15+ # (ARM management plane), so no public/data-plane access from the Terraform
16+ # runner is required.
17+ public_network_access_enabled = false
1918 network_rules {
2019 default_action = " Deny"
21- ip_rules = [local . my_ip ]
2220 }
2321}
2422
25- # Share to use for the Azure Function, for the WEBSITE_CONTENTSHARE setting
26- resource "azurerm_storage_share" "durable_function_storage" {
27- name = azurerm_storage_account. durable_function_storage . name
28- storage_account_name = azurerm_storage_account. durable_function_storage . name
29- quota = 50
23+ # Share to use for the Azure Function, for the WEBSITE_CONTENTSHARE setting.
24+ # Created through the ARM management plane (azapi) rather than the storage data
25+ # plane, so it works even with public_network_access_enabled = false.
26+ resource "azapi_resource" "durable_function_storage_share" {
27+ type = " Microsoft.Storage/storageAccounts/fileServices/shares@2023-01-01"
28+ name = azurerm_storage_account. durable_function_storage . name
29+ parent_id = " ${ azurerm_storage_account . durable_function_storage . id } /fileServices/default"
30+ body = {
31+ properties = {
32+ shareQuota = 50
33+ }
34+ }
3035}
3136
3237# Private endpoints for the Durable function storage account
@@ -114,23 +119,28 @@ resource "azurerm_storage_account" "mcd_agent_storage" {
114119 allow_nested_items_to_be_public = false
115120 infrastructure_encryption_enabled = true
116121
117- # Using this approach to allow access from the IP address running Terraform,
118- # this is required for the creation of the container below and run TF plan/apply
119- # in the future.
120- # You can manually disable public access completely after deploying this module,
121- # just remember to restore this rule before executing TF again.
122- public_network_access_enabled = true
122+ # The account is kept fully private: access is only possible through the
123+ # private endpoint below. The container is created via the azapi provider
124+ # (ARM management plane), so no public/data-plane access from the Terraform
125+ # runner is required.
126+ public_network_access_enabled = false
123127 network_rules {
124128 default_action = " Deny"
125- ip_rules = [local . my_ip ]
126129 }
127130}
128131
129- # Container used by the MC agent
130- resource "azurerm_storage_container" "mcd_agent_storage_container" {
131- name = local. agent_data_storage_container_name
132- storage_account_name = azurerm_storage_account. mcd_agent_storage . name
133- container_access_type = " private"
132+ # Container used by the MC agent.
133+ # Created through the ARM management plane (azapi) rather than the storage data
134+ # plane, so it works even with public_network_access_enabled = false.
135+ resource "azapi_resource" "mcd_agent_storage_container" {
136+ type = " Microsoft.Storage/storageAccounts/blobServices/containers@2023-01-01"
137+ name = local. agent_data_storage_container_name
138+ parent_id = " ${ azurerm_storage_account . mcd_agent_storage . id } /blobServices/default"
139+ body = {
140+ properties = {
141+ publicAccess = " None"
142+ }
143+ }
134144}
135145
136146# Private endpoint for the MC agent storage account
@@ -160,7 +170,7 @@ resource "azurerm_storage_management_policy" "mcd_agent_storage_lifecycle" {
160170 enabled = true
161171 filters {
162172 blob_types = [" blockBlob" , " appendBlob" ]
163- prefix_match = [" ${ azurerm_storage_container . mcd_agent_storage_container . name } /${ local . agent_data_store_data_prefix } " ]
173+ prefix_match = [" ${ azapi_resource . mcd_agent_storage_container . name } /${ local . agent_data_store_data_prefix } " ]
164174 }
165175 actions {
166176 base_blob {
@@ -173,7 +183,7 @@ resource "azurerm_storage_management_policy" "mcd_agent_storage_lifecycle" {
173183 enabled = true
174184 filters {
175185 blob_types = [" blockBlob" , " appendBlob" ]
176- prefix_match = [" ${ azurerm_storage_container . mcd_agent_storage_container . name } /${ local . agent_data_store_data_prefix } /tmp" ]
186+ prefix_match = [" ${ azapi_resource . mcd_agent_storage_container . name } /${ local . agent_data_store_data_prefix } /tmp" ]
177187 }
178188 actions {
179189 base_blob {
0 commit comments