c# - 来自 SQL Server CLR Proc 的 Azure 存储中的 Blob 列表,未获得完整列表
问题描述
我得到了前 30 名左右,而不是包含 100+ 的完整列表,这是为什么呢?
我从 SQL Server 的 Azure 存储中的 blob 列表中获得了此代码。我很好地获得了我需要的部分内容,但不是该容器内所有内容的列表,所有这些都是相同的文件类型。
public partial class StoredProcedures
{
[Microsoft.SqlServer.Server.SqlProcedure]
public static void SqlStoredProcedure1 ()
{
// Put your code here
string StorageAccount = "myaccount";
string StorageKey = "accountkey";
string containername = "mycontainer";
string requestMethod = "GET";
string mxdate = "";
string storageServiceVersion = "2014-02-14";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(string.Format(CultureInfo.InvariantCulture,
"https://{0}.blob.core.windows.net/{1}?restype=container&comp=list",
StorageAccount,
containername
));
req.Method = requestMethod;
//specify request header
mxdate = DateTime.UtcNow.ToString("R");
string canonicalizedHeaders = string.Format(
"x-ms-date:{0}\nx-ms-version:{1}",
mxdate,
storageServiceVersion);
string canonicalizedResource = string.Format("/{0}/{1}\ncomp:list\nrestype:container", StorageAccount, containername);
string stringToSign = string.Format(
"{0}\n\n\n\n\n\n\n\n\n\n\n\n{1}\n{2}",
requestMethod,
canonicalizedHeaders,
canonicalizedResource);
HMACSHA256 hmac = new HMACSHA256(Convert.FromBase64String(StorageKey));
string signature = Convert.ToBase64String(hmac.ComputeHash(Encoding.UTF8.GetBytes(stringToSign)));
String authorization = String.Format("{0} {1}:{2}",
"SharedKey",
StorageAccount,
signature
);
string AuthorizationHeader = authorization;
req.Headers.Add("Authorization", AuthorizationHeader);
req.Headers.Add("x-ms-date", mxdate);
req.Headers.Add("x-ms-version", storageServiceVersion);
DataTable dt = new DataTable();
using (HttpWebResponse response = (HttpWebResponse)req.GetResponse())
{
var stream = response.GetResponseStream();
StreamReader reader = new StreamReader(stream);
string content = reader.ReadToEnd();
StringReader theReader = new StringReader(content);
DataSet theDataSet = new DataSet();
theDataSet.ReadXml(theReader);
dt = theDataSet.Tables[2];
}
string blobs = "";
foreach (DataRow item in dt.Rows)
{
blobs += item[0].ToString() + ";";
}
SqlContext.Pipe.Send(blobs);
}
}
解决方案
推荐阅读
- javascript - 使用Javascript检查整数是否为整数
- python - 我想在某个路径上移动海龟,同时,我想将它移动经过的所有像素保存在变量列表中
- bash - 如何在bash中对浮点变量求和?
- python - Django TestCase 不再通过:错误的 url
- sql - Azure SQL - 如何从输出中删除属性文本
- sql-server - 在子查询中获取 DISTINCT 值
- linux - 受限设备上的 MPI 是 Linux 上进程间通信的好选择吗?
- jquery - 为什么我有一个 JS 错误“我是未定义的 jquery.datatables.min.js”
- go - dynamodbattribute.MarshalMap 返回空地图
- git - 从 Visual Studio 2017 获取和提取的 Git 未获得最新提交