azure-storage-blobs

C# retrieving a list of blobs from Azure

家住魔仙堡 提交于 2019-11-30 19:51:22
问题 I need to have some archive cleanup code to remove old Azure logs after a certain retention period has occurred. I am aware that I can do this: CloudStorageAccount storageAccount = CloudStorageAccount.Parse(""); CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); CloudBlobContainer container = blobClient.GetContainerReference("ctr"); var blobList = container.ListBlobs(); foreach(var blob in blobList) { logger.Info($"Blob Name: {blob.Uri}"); } However within my container the

How do I force Azure CDN content to be purged or invalidated?

会有一股神秘感。 提交于 2019-11-30 19:16:57
I have content that rarely changes that I want to serve over the Azure CDN for performance reasons. When the content does change, though, it's important that the updated data is immediately available. Ideally, I'd be able to set a long TTL but then proactively tell the CDN to expire content when I update it. How can I accomplish this? There is no cache invalidation or purge API right now, and I would rather not set a short TTL. In 2015 December the Azure team added the ability to refresh or purge the CDN via REST API ( https://msdn.microsoft.com/en-us/library/mt634451.aspx ). In the beginning,

Transactional Access of Azure Blob Storage

本秂侑毒 提交于 2019-11-30 18:36:57
I would like to store files in Azure Blob Storage. So far so good. I also would like to store addtional meta-data about the file; for that I use a Azure SQL Database (so I can easily query for files on the blob storage). So when I add a new file to the store I would like to make sure, that the blob as well as the meta-data was successfully written. So using something like a transaction-context comes to my mind. Is there any way, to create such a transaction-context using blob storage as well as sql storage? There is nothing built-in that will do this as far as I know; you will need to manage

Cannot delete blob: There is currently a lease on the blob and no lease ID was specified in the request

二次信任 提交于 2019-11-30 18:14:47
When I attempt to delete a blob from my storage account container, I get an error message, " There is currently a lease on the blob and no lease ID was specified in the request. " I have 4 virtual machine instances. I also have 8 virtual machine disks, 4 of which are in use (one by each of the virtual machine instances). Strangely, I have 10 blobs listed in my single storage account's lone container, called vhds . Here is a screenshot of the 10 blobs , highlighting the two that I cannot delete. Can anyone give me guidance on how to delete these blobs? I have no use for them and I'd like to cut

Using Parallel.Foreach in a small azure instance

若如初见. 提交于 2019-11-30 16:11:57
I have a WebRole running on a small instance. This WebRole has a method that uploads a large amount of files to BLOB storage. According to the Azure instances specs, a small instance has only 1 core . So when uploading those blobs, will Parallel.Foreach give me any benefits over a regular Foreach ? You would be much better served by focusing on using the aysnc versions of the blob storage APIs and/or Stream APIs so that you are I/O bound rather than CPU bound. Anywhere there is a BeginXXX API you should use it by wrapping it up with Task.Factory.FromAsync and the using a continuation from

StorageException when downloading a large file over a slow network

感情迁移 提交于 2019-11-30 15:46:10
I'm using the NuGet package WindowsAzure.Storage version 4.2.1. The following code tries to download a blob from a storage container that is in a distant datacenter. try { var blobRequestOptions = new BlobRequestOptions { RetryPolicy = new ExponentialRetry(TimeSpan.FromSeconds(5), 3), MaximumExecutionTime = TimeSpan.FromMinutes(60), ServerTimeout = TimeSpan.FromMinutes(60) }; using (var fileStream = File.Create(localPath)) { blockBlob.DownloadToStream(fileStream, null, blobRequestOptions); } } catch (Exception e) { Console.WriteLine(e.Message); } However, sometimes it downloads for ~10 minutes

Handling FileContentResult when file is not found

十年热恋 提交于 2019-11-30 13:17:24
I have a controller action that downloads a file from an azure blob based on the container reference name (i.e. full path name of the file in the blob). The code looks something like this: public FileContentResult GetDocument(String pathName) { try { Byte[] buffer = BlobStorage.DownloadFile(pathName); FileContentResult result = new FileContentResult(buffer, "PDF"); String[] folders = pathName.Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries); // get the last one as actual "file name" based on some convention result.FileDownloadName = folders[folders.Length - 1]; return result;

How to delete a folder within an Azure blob container

久未见 提交于 2019-11-30 11:08:23
I have a blob container in Azure called pictures that has various folders within it (see snapshot below): I'm trying to delete the folders titled users and uploads shown in the snapshot, but I keep the error: Failed to delete blob pictures/uploads/. Error: The specified blob does not exist. Could anyone shed light on how I can delete those two folders? I haven't been able to uncover anything meaningful via Googling this issue. Note: ask me for more information in case you need it Windows Azure Blob Storage does not have the concept of folders. The hierarchy is very simple: storage account >

Query JSON data from Azure Blob Storage with jQuery

主宰稳场 提交于 2019-11-30 10:23:18
I have some data in an Azure blob storage. The data is JSON and it has been saved with the "application/json" content type. My app would be hosted at "myapp.com", a domain that contains a CNAME to "myapp.cloudapp.net". I guess I should create a custom domain name like "storage.myapp.com" that poins to my Azure storage. But then? Can I use JSONP or other way to make JSON ajax calls to Azure storage? How would be the better way to do this? Thanks a lot. Well, apparently Azure blob storage doesn't support JSONP straightaway, but it can be done. For example, if I store this JSON in an Azure blob:

Azure Blob Storage returns 404 on PUT

只愿长相守 提交于 2019-11-30 09:41:24
问题 I created new blob storage; set CORS to allow all (*) origins; created new container (dev); set container access policy to "Container". Now when I'm trying to upload file (file.txt) to my container I get 404 ResourceNotFound "The specified resource does not exist." response. I make following request from Postman: PUT /dev/file.txt HTTP/1.1 Host: mystorageaccount.blob.core.windows.net x-ms-blob-type: BlockBlob x-ms-date: Thu, 13 Oct 2016 09:00:00 GMT x-ms-version: 2015-02-21 x-ms-blob-content