Setting Azure storage account as cache location
Problem reported by Ryan Allan - August 21 at 4:03 PM
Resolved
We are attempting to set our cache location to an Azure storage account and it appears to have worked but is throwing an exception during pre-caching. The exception is this:
Message = "Specified method is not supported."
"   at Microsoft.WindowsAzure.Storage.Blob.BlobWriteStreamBase.get_Length()\r\n   at GleamTech.IO.DelegatingStream.get_Length()
 
I did a quick google search and this appears to have changed a while back during an update to the MicrosoftAzure.Storage package. Is there a bug in the DocumentUltimate package regarding this?

5 Replies

Reply to Thread
1
Cem Alacayir Replied
Employee Post
We are using an older version (7.2.1) of WindowsAzure.Storage internally due to net40 support (after this version it requires net45). However I think the error you get is not a bug or related to WindowsAzure.Storage version. It's probably caused because you pass a stream without length to PreCache method. Try to read your original stream into a MemoryStream or a byte array and pass that to PreCache method.
 
For reference:
0
I did make a few changes to how we are calling pre-cache and this seems to have fixed the issue.
0
This appears to be a red herring. I applied the code changes to my local development environment and ran and had no problems, i can pre-cache and view files while using Azure Storage Account as cache location. However, i have two colleagues that cannot get this to work with the same code out of our GIT repository and if i deploy the code to Azure App Services, it does not work. So, I am the only one that has successfully gotten pre-caching and viewing from Azure Storage as cache location to work and I for the life of me cannot figure out what is different about my environment. All three failing environments throw the same exception that was posted in the beginning of this thread. Any pointers as to what to look into would be appreciated.
 
And P.S. I have tried with both MemoryStream and Byte arrays for pre-caching.
0
Hi, I am experiencing the exact same issue. I tried using both streams and byte arrays for pre-caching however it still gives an error. I am pre-caching from a .Net Framework 4.7.2 console application and am using the latest version of WIndowsAzure.Storage (v9.3.2).
 
This seems to happen with DOCX files - caching PDF and XLSX works fine.
 
The relevant part of the stack trace is:
   at Microsoft.WindowsAzure.Storage.Blob.BlobWriteStreamBase.get_Length()
   at _meA.vmethod_1(_KaC class2615_0)
   at _4Gh.method_4()
   at _sUH.vmethod_3(_phH class5113_0)
   at _IPG.method_1(_GWd class2652_0, _lbG class5137_0)
   at _IPG.imethod_0(_GWd class2652_0)
   at _zgb.Interface190.imethod_0(_GWd class2652_0)
   at _2hh.method_108(Stream stream_0, String string_3, _7Tg saveOptions_0)
   at _FaJ._fsI(ConversionContext conversionContext, Action`1 diskSaveCallback, Action`1 streamSaveCallback)
   at GleamTech.DocumentUltimate.DocumentConverter._fXj(OutputContext outputContext, Nullable`1 engine)
   at GleamTech.DocumentUltimate.AspNet.DocumentCache._Fak._FXj(Stream cacheFileStream)
   at GleamTech.Caching.FileCache._Ue(IDisposable context, FileSystem fileSystem, _6N cacheFileInfo, Action`1 createAction)
   at GleamTech.Caching.FileCache.GetOrAdd(FileCacheKey cacheKey, Action`1 createAction)
   at GleamTech.DocumentUltimate.AspNet.DocumentCache._FQi._FhI(Stream cacheFileStream)
   at GleamTech.Caching.FileCache._Ue(IDisposable context, FileSystem fileSystem, _6N cacheFileInfo, Action`1 createAction)
   at GleamTech.Caching.FileCache.GetOrAdd(FileCacheKey cacheKey, Action`1 createAction)
0
Cem Alacayir Replied
Employee Post
FYI, this is now fixed. Sorry for the late fix.
 
Thanks to Steven's feedback;
This seems to happen with DOCX files - caching PDF and XLSX works fine.
I was able to replicate the issue. It indeed happens only with conversion of some document types like DOCX to PDF where the Stream.Length property is called. This is caused by the bad implementation of CloudBlobStream in WindowsAzure.Storage library (I think they should have implemented Length property properly, the problem exists even in their latest version) but we could fix it by wrapping it.
 
The fix is included in dependency GleamTech.Core v3.1.6 so manually update that NuGet package and rebuild your project. This is because even if you have the latest version GleamTech.DocumentUltimate v4.3.5, it binds to GleamTech.Core v3.1.5 in NuGet and not to v3.1.6 so you should explicitly update GleamTech.Core package in NuGet Package Manager. Also make sure you have GleamTech.DocumentUltimate v4.2.0 at minimum. The next version of GleamTech.DocumentUltimate will bind to GleamTech.Core v3.1.6.
 
Version 3.1.6 - October 16, 2018
  - Fixed: AzureBlobFileSystem.CreateFile will return a MemoryStream instead of CloudBlobStream as calling CloudBlobStream.Length property throws "Specified method is not supported." error and this breaks conversion of some document types (e.g. docx to pdf) in DocumentUltimate (when AzureBlob location is used for DocumentCache).

Reply to Thread