如何将Azure存储Blob JSON导入Azure SQL Server

时间:2019-02-25 08:52:02

标签: json azure-sql-database azure-blob-storage 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记录,如何根据它定义我的sql表,以及如何将JSON数据导入到Azure SQL Server中:(

2 个答案:

答案 0 :(得分:1)

您可以使用Azure数据工厂Copy Activity将blob数据直接传输到sql服务器。请将输入配置为Azure Blob Storage Connector,将输出配置为Azure SQL Database Connector

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

答案 1 :(得分:1)

请查看以下文档:Import JSON documents into SQL Server(Azure SQL Database)

它显示了如何将Azure Storage Blob JSON导入Azure SQL Server。并提供了演示:

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

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

希望这会有所帮助。