【问题标题】:Can't Upload multiple azure blobs contents ( text and Image) to Azure SQL table无法将多个 azure blob 内容(文本和图像)上传到 Azure SQL 表
【发布时间】:2018-12-07 12:35:47
【问题描述】:

目前我只能使用以下触发器上传一个 blobtype(text)

#r "System.Configuration"
#r "System.Data"
using System.Configuration;
using System.Data.SqlClient;
using System.Threading.Tasks;
using System;

public static void Run(Stream myBlob, string name, TraceWriter log)
{
    log.Info($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {myBlob.Length} Bytes");
    string detail = ($"{name}");


    var str = ConfigurationManager.ConnectionStrings["sqldb_connection"].ConnectionString;
    using (SqlConnection conn = new SqlConnection(str))
    {
        conn.Open();
  var text = "INSERT INTO PhotoTable(CreatedAt,UpdatedAt,IsDeleted, Url, Title) " +
           "VALUES (SYSDATETIMEOFFSET(),SYSDATETIMEOFFSET(), 'true', 'yrhrh', @Name)";
        using (SqlCommand cmd = new SqlCommand(text, conn))
        {
            cmd.Parameters.AddWithValue("@Name", name);
            // Execute the command and log the # rows affected.
            var rows = cmd.ExecuteNonQueryAsync();
            log.Info($"{rows} rows were updated");
        }
    }
}

有 2 个问题 01)他们有什么方法可以同时上传两种类型的Azure SQLstorage吗?(例如文本blob和图像blob)

02) 使用此触发器,我只获取 blob 存储的 ID 而不是内容,这也是一个问题,我也可以通过任何方式获取 blob 存储的内容?? ,

非常感谢您的帮助,谢谢

【问题讨论】:

  • 提供的答案对您的方案有帮助吗?

标签: azure xamarin.forms azure-sql-database azure-blob-storage


【解决方案1】:

1) 可以使用 SSIS 将不同类型的文件上传到 Azure SQL,下面的视频tutorial 向您展示了如何做到这一点的分步指南

2) 第二个,你可以使用 OPENROWSET,解析存储在 Blob 存储中的文件并将文件内容作为一组行返回 以下示例显示了将文件内容加载到 SQL 数据库中的 BULK INSERT 命令:

BULK INSERT Product
FROM 'data/product.dat'
WITH ( DATA_SOURCE = 'MyAzureBlobStorageAccount');

更多信息可以找到here

【讨论】:

    猜你喜欢
    • 2015-05-15
    • 2014-06-21
    • 2015-10-16
    • 2017-04-26
    • 2020-06-12
    • 2020-12-22
    • 2021-12-30
    • 2013-01-01
    • 2018-12-17
    相关资源
    最近更新 更多