Tag: Azure的存储

Azure存储容器大小

如何在Azure存储中获取容器大小? 我通过C#API访问Azure存储: var account = CloudStorageAccount.Parse(ConfigurationManager.AppSettings[“AzureStoragePrimary”]); var client = account.CreateCloudBlobClient(); var container = client.GetContainerReference(“myContainer”);

如何在不使用临时文件的情况下将.NET对象序列化为Azure Blob存储?

我想将.NET对象存储到Azure Blob存储中。 目前我使用TextWriter将其序列化为XML文件( episodeList是我想要序列化的对象): XmlAttributeOverrides overrides = new XmlAttributeOverrides(); XmlAttributes Xmlattr = new XmlAttributes(); Xmlattr.XmlRoot = new XmlRootAttribute(“EPISODES”); overrides.Add(typeof(List), Xmlattr); XmlSerializer serializer = new XmlSerializer(typeof(List), overrides); TextWriter textWriter = new StreamWriter(@”C:\movie.xml”); serializer.Serialize(textWriter, episodeList); textWriter.Close(); 然后将文件上传到Blob存储: CloudBlobClient blobStorage = createOrGetReferenceOfBlobStorage(folderName); string uniqueBlobName = string.Format(“{0}/{1}”, folderName, fileName); CloudBlockBlob blob = clouBblockBlobPropertySetting(blobStorage, uniqueBlobName, “.txt”); using (StreamWriter writer = […]

Azure存储计算的MD5与现有属性不匹配

我正在尝试通过ashx传递Azure存储blob。 在blockBlob.DownloadToStream(memoryStream)上抛出以下exception: Microsoft.WindowsAzure.Storage.StorageException: Calculated MD5 does not match existing property 我知道它找到了正确的blob。 如果我放入一个不存在的容器和路径,那么它会给我一个404exception。 我已经用Google搜索了可能导致此错误的提示,但没有任何有用的信息。 有没有人对可能导致这种情况的原因有任何想法? 在过去的几天里,我以不同的方式重写了这段代码,但它总是在DownloadToStream上消失。 using Microsoft.WindowsAzure; using Microsoft.WindowsAzure.Storage; using Microsoft.WindowsAzure.Storage.Auth; using Microsoft.WindowsAzure.Storage.Blob; public void ProcessRequest(HttpContext context) { // Retrieve storage account from connection string. Microsoft.WindowsAzure.Storage.CloudStorageAccount storageAccount = Microsoft.WindowsAzure.Storage.CloudStorageAccount.Parse(Microsoft.WindowsAzure.CloudConfigurationManager.GetSetting(“StorageConnectionString”)); // Create the blob client. CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); // Retrieve reference to a previously created […]

如何使用Linq查询Azure存储表?

我不知道到底在哪里,但我对此有错误的想法。 我试图在第一个实例中使用linq查询azure存储表。 但我无法弄清楚它是如何完成的。 从各种来源看我有以下几点: List blogs = new List(); CloudStorageAccount storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue(“BlogConnectionString”)); CloudTableClient tableClient = storageAccount.CreateCloudTableClient(); CloudTable blogTable = tableClient.GetTableReference(“BlogEntries”); try { TableServiceContext tableServiceContext = tableClient.GetTableServiceContext(); TableServiceQuery query = (from blog in blogTable.CreateQuery() select blog).AsTableServiceQuery(tableServiceContext); foreach (BlogEntry blog in query) { blogs.Add(new BlogViewModel { Body = blog.Body }); } } catch { } 在我搞砸之前,我可能已经把它靠近了。 […]

CloudBlob.DownloadToStream返回null

我正在尝试通过流从cloudBlob下载文件。 我参考这篇文章CloudBlob 这是下载blob的代码 public Stream DownloadBlobAsStream(CloudStorageAccount account, string blobUri) { Stream mem = new MemoryStream(); CloudBlobClient blobclient = account.CreateCloudBlobClient(); CloudBlockBlob blob = blobclient.GetBlockBlobReference(blobUri); if (blob != null) blob.DownloadToStream(mem); return mem; } 并将代码转换为字节数组 public static byte[] ReadFully(Stream input) { byte[] buffer = new byte[16 * 1024]; using (MemoryStream ms = new MemoryStream()) { int read; while […]

C#生成Azure表存储ConnectionString

我想使用azure subscriptionId和azureApiKey为azure表存储生成connectionString。 我找到了以下Microsoft库: https : //github.com/Azure/azure-libraries-for-net/tree/master但无法理解如何在此处生成connectionString。 我甚至找不到合适的方法。 我是否需要其他数据才能生成ConnectionString?

如何获取Azure CloudBlobContainer的大小

我正在为我的应用程序创建一个.net包装器服务,该服务利用Azure Blob Storage作为文件存储。 我的应用程序为我系统上的每个“帐户”创建一个新的CloudBlobContainer 。 每个帐户都限制为最大存储量。 查询Azure CloudBlobContainer的当前大小(空间利用率)的最简单,最有效的方法是什么?

我是否可以创建一个Azure Webjob,它将function公开给仪表板但不使用Azure存储?

我想创建一个Azure Webjob来满足批处理需求(特别是它会不断迭代SQL Azure数据库表,获取某些记录,执行一些操作然后更新表)。 我不需要Azure存储。 在这种情况下,我仍然可以将我的方法暴露给Azure函数调用仪表板吗? 或者是Azure存储属性是唯一暴露的方法? 作为一个例子,我可能有一个function: ShowTotalNumRecordsProcessedToday() 我希望公开并能够从仪表板调用。 我已经创建了一些公共测试function,但它们没有显示在仪表板中。 我可以在我的场景中这样做吗?

指定的容器不存在

我遇到了这个错误The specified container does not exist. 让我解释, CloudBlobClient blobStorage = GetBlobStorage(“upload”); CloudBlockBlob blob = BlobPropertySetting(blobStorage, Guid.NewGuid().ToString().ToLower() + Path.GetExtension(file.FileName)); blob.UploadFromStream(file.InputStream); public static CloudBlobClient GetBlobStorage(string cloudBlobContainserName) { CloudBlobClient blobStorage; try { var storageAccount = CloudStorageAccount.FromConfigurationSetting(“StorageConnectionString”); blobStorage = storageAccount.CreateCloudBlobClient(); CloudBlobContainer container = blobStorage.GetContainerReference(cloudBlobContainserName); container.CreateIfNotExist(); var permissions = container.GetPermissions(); permissions.PublicAccess = BlobContainerPublicAccessType.Container; container.SetPermissions(permissions); } catch (Exception ex) { Logger.LogError(Log4NetLogger.Category.Exception, […]

如何调用ffmpeg.exe来转换Windows Azure上的音频文件?

我在Windows Azure上运行Web角色以接收AAC音频文件(由base64字符串上传)并将它们存储到blob中。 它现在工作正常。 接下来,我还必须将它们转换为MP3并将MP3存储到blob中。 我决定使用像ffmpeg.exe -i path .aac path .mp3这样的东西。 问题在于: 如何在Web角色的Web服务中调用外部ffmpeg.exe ? 路径是什么? 如果你知道,请帮助我。 先感谢您。