ferj
ferj

Reputation: 111

Facing Issues on Deploying template for Azure File Share Storage Account

I am trying to create a storage account with file share and the rest of the services included. when I execute the template it throws the below error.

Status Message: XML specified is not syntactically valid. RequestId:5be13537-701a-0056-1f1d-0a506f000000 Time:2021-02-23T19:53:49.1937194Z (Code:InvalidXmlDocument) CorrelationId: 21fe81f4-b917-4813-ade5-9b96f3b688d6

The storage account's blob, queue, table get provisioned don't know why it throws an error on file share provisioning. Any help guys.

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "storageAccountname": {
            "type": "String"
        },
        "location": {
            "type": "String"
        },
        "skuname": {
            "type": "String"
        },
        "tags": {
            "type": "Object"
        },
        "accessTier": {
            "type": "String"
        }
    },
    "variables": {},
    "resources": [
        {
            "type": "Microsoft.Storage/storageAccounts",
            "apiVersion": "2020-08-01-preview",
            "name": "[parameters('storageAccountname')]",
            "location": "[parameters('location')]",
            "tags": "[parameters('tags')]",
            "sku": {
                "name": "[parameters('skuname')]",
                "tier": "Standard"
            },
            "kind": "StorageV2",
            "properties": {
                "allowBlobPublicAccess": true,
                "networkAcls": {
                    "bypass": "AzureServices",
                    "virtualNetworkRules": [],
                    "ipRules": [],
                    "defaultAction": "Allow"
                },
                "supportsHttpsTrafficOnly": true,
                "encryption": {
                    "services": {
                        "file": {
                            "keyType": "Account",
                            "enabled": true
                        },
                        "blob": {
                            "keyType": "Account",
                            "enabled": true
                        }
                    },
                    "keySource": "Microsoft.Storage"
                },
                "accessTier": "[parameters('accessTier')]"
            }
        },
        {
            "type": "Microsoft.Storage/storageAccounts/fileServices",
            "apiVersion": "2020-08-01-preview",
            "name": "[concat(parameters('storageAccountname'), '/default')]",
            "dependsOn": [
                "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountname'))]"
            ],
            "sku": {
                "name": "[parameters('skuname')]",
                "tier": "Standard"
            },
            "properties": {
                "protocolSettings": {
                    "smb": {}
                },
                "cors": {
                    "corsRules": []
                },
                "shareDeleteRetentionPolicy": {
                    "enabled": true,
                    "days": 7
                }
            }
        }
    ]
}

Upvotes: 3

Views: 2468

Answers (3)

Nancy Xiong
Nancy Xiong

Reputation: 28264

From this azure quickstart template, we don't need to provide the resource of the type Microsoft.Storage/storageAccounts/fileServices when you create a standard storage account.

When we only include resource Microsoft.Storage/storageAccounts with kind StorageV2, it will provision all these services: blobServices,fileServices,queueServices,tableServices at the same time.

{
    "type": "Microsoft.Storage/storageAccounts",
    "apiVersion": "2019-06-01",
    "name": "[parameters('storageAccountName')]",
    "location": "[parameters('location')]",
    "kind": "StorageV2",
    "sku": {
        "name": "Standard_LRS",
        "tier": "Standard"
    },
    "properties": {
        "accessTier": "Hot"
    }
},

If you only would like to create fileservices, you could select a FileStorage kind of storage account type with Premium performance tiers. The working sample like this:

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "storageAccountname": {
            "type": "String"
        },
        "location": {
            "type": "String"
        },
        "skuname": {
            "type": "String"
        },
        "tags": {
            "type": "Object"
        }
        // "accessTier": {
        //     "type": "String"
        // }
    },
    "variables": {},
    "resources": [
        {
            "type": "Microsoft.Storage/storageAccounts",
            "apiVersion": "2020-08-01-preview",
            "name": "[parameters('storageAccountname')]",
            "location": "[parameters('location')]",
            "tags": "[parameters('tags')]",
            "sku": {
                "name": "[parameters('skuname')]",
                "tier": "Premium"
            },
            "kind": "FileStorage",
            "properties": {
                "allowBlobPublicAccess": true,
                "networkAcls": {
                    "bypass": "AzureServices",
                    "virtualNetworkRules": [],
                    "ipRules": [],
                    "defaultAction": "Allow"
                },
                "supportsHttpsTrafficOnly": true,
                "encryption": {
                    "services": {
                        "file": {
                            "keyType": "Account",
                            "enabled": true
                        },
                        "blob": {
                            "keyType": "Account",
                            "enabled": true
                        }
                    },
                    "keySource": "Microsoft.Storage"
                }
                // "accessTier": "[parameters('accessTier')]"
            }
        }
    ]
}

For more information, read https://learn.microsoft.com/en-us/azure/storage/common/storage-account-overview#performance-tiers

Upvotes: 4

Vinod Buddi
Vinod Buddi

Reputation: 11

Yes, when the storage account kind is changed to StorageV2, is allowing me to add fileshare.

Upvotes: 1

Ed Withers
Ed Withers

Reputation: 11

I was running into the same error and chased it down to the "protocolSettings" with the empty "SMB" entry. Removing that block from my template eliminated the error and the resource was created with the default values.

It may not be necessary to include the fileservices resource type, but I make it a standard practice to include all four (blob, file, queue, and table) in case I later want to add containers/shares/etc. in the template so the references to their parents will work (and to maintain my sanity in remembering the structure when I look at the template months later.)

Upvotes: 1

Related Questions