Search code examples
jsonazure-sql-databaseazure-blob-storageazure-sql-server

How to import Azure Storage Blob JSON into Azure SQL Server


{
    "Events":    
        [
            {
            "dataOne":7.5555555555555555,    
            "dataTwo":7.5555555555555555,    
            "dataFive":1025,
            "dataSix":0,
            "dataSeven":1025,
            "dateTimeLocal":1234567890,     
            "dateTimeUTC":1234567890         
            }
        ],
    "infoType":"type1",
    "deviceID":"00000000000000000",         
    "dateTimeLocal":1234567890,
    "dateTimeUTC":1234567890,
    "EventProcessedUtcTime":"20xx-0x-xxT0x:0x:x.4781329Z",
    "PartitionId":1,
    "EventEnqueuedUtcTime":"20xx-0x-xxT0x:0x:x.3850000Z"
}

Here is a JSON record of my data, how do I define my sql table according to it, and how do I import the JSON data in to Azure SQL Server : (


Solution

  • Please look at this doucment:Import JSON documents into SQL Server(Azure SQL Database)

    It shows how to import Azure Storage Blob JSON into Azure SQL Server. And provides the demos:

    1. Import a JSON document into a single column
    2. Import multiple JSON documents
    3. Import JSON documents from Azure File Storage
    4. Import JSON documents from Azure Blob Storage
    5. Parse JSON documents into rows and columns

    Demo SQL:

    CREATE EXTERNAL DATA SOURCE MyAzureBlobStorage
     WITH ( TYPE = BLOB_STORAGE,
            LOCATION = 'https://myazureblobstorage.blob.core.windows.net',
            CREDENTIAL= MyAzureBlobStorageCredential);
    BULK INSERT Product
    FROM 'data/product.dat'
    WITH ( DATA_SOURCE = 'MyAzureBlobStorage');
    

    You just need to follow the tutorial.

    Hope this helps.