How to upload the snapshot json into the storage account with Ev2 ARM template?

Nathon 0 Reputation points Microsoft Employee
2024-10-07T20:46:50.2366667+00:00

I'm trying to use the ARM template and EV2 to upload the snapshot json into the blob storage account. Is there any existing template or examples to support this action?

Azure Storage Accounts
Azure Storage Accounts
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
3,405 questions
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
3,105 questions
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,323 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Keshavulu Dasari 4,110 Reputation points Microsoft External Staff
    2024-10-07T22:20:29.91+00:00

    Hi Nathon,
    To upload a snapshot JSON into a blob storage account using an ARM template with Ev2, you can use deployment scripts within your ARM template. Here’s a general approach to achieve this:

    1. Create a Storage Account: Define the storage account in your ARM template.
    2. Use Deployment Scripts: Utilize the deployment Scripts resource to execute a script that uploads your JSON file to the storage account.
    {
      "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
      "contentVersion": "1.0.0.0",
      "resources": [
        {
          "type": "Microsoft.Resources/deploymentScripts",
          "apiVersion": "2020-10-01",
          "location": "[resourceGroup().location]",
          "properties": {
            "azPowerShellVersion": "3.0",
            "scriptContent": "az storage blob upload --account-name <storageAccountName> --container-name <containerName> --name <blobName> --file <filePath>",
            "supportingScriptUris": [],
            "timeout": "PT30M",
            "cleanupPreference": "OnSuccess",
            "retentionInterval": "P1D",
            "forceUpdateTag": "1.0"
          }
        }
      ]
    }
    
    

    Replace <storageAccountName>, <containerName>, <blobName>, and <filePath> with your actual values

    For more detailed information and examples, you can refer to the Azure Resource Manager documentation on deployment scripts:
    https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/deployment-script-template#sample-templates

    To Follow:

    1. Define Parameters: Set parameters for the storage account name, location, and container name.
    2. Create Storage Account Resource: Define the storage account resource in the template.
    3. Add Deployment Script: Use the deployment Scripts resource to run an Azure CLI command that uploads the JSON file to the specified blob container.

    This script to upload the snapshot.json file to the specified container in the storage account.

    Please let us know if you have any further queries. I’m happy to assist you further.  

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.