如何将 Azure 存储 Blob JSON 导入 Azure SQL 服务器

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"
}

这里有一条JSON记录我的数据,如何根据它来定义我的sqltable,以及如何将JSON数据导入到到 Azure SQL 服务器:(

您可以使用 Azure 数据工厂 Copy Activity to transfer your blob data into sql server directly. Please configure the input as Azure Blob Storage Connector and output as Azure SQL Database Connector

关于列映射,请参考这个link:https://docs.microsoft.com/en-us/azure/data-factory/copy-activity-schema-and-type-mapping。数组 属性 可以作为字符串存储在 sql 数据库列中。

请看这个文档:Import JSON documents into SQL Server(Azure SQL Database)

它展示了如何将 Azure 存储 Blob JSON 导入到 Azure SQL 服务器中。并提供了demo:

  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

演示 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');

您只需要按照教程进行即可。

希望对您有所帮助。