We have some legacy code that uploads strings to blobs in an Azure Storage Account, using the old Microsoft.WindowsAzure.Storage.Blob library. The new version of the code uses the newer Microsoft.Azure.Storage.Blob library. Both the library provide the CloudBlockBlob.UploadTextAsync method, that lets you to upload a string directly to a blob. The two different versions of our code (the legacy one and the new one), are exactly the same and use the following instruction:
await new CloudBlockBlob(new Uri(string.Format("[SAS]", "[blobName]"))).UploadTextAsync("[content]");
where [SAS], [blobName] and [content] are just placeholders; in production:
[SAS]is replaced by our Azure Storage Account’s SAS.[blobName]is replaced by the name of the blob to create.[content]is replaced by the content of the blob.
Running the legacy version (the one using the Microsoft.WindowsAzure.Storage.Blob library), everything works fine, but running the new version (the one using the Microsoft.Azure.Storage.Blob library) raises a Microsoft.Azure.Storage.StorageException, saying 'The specified resource does not exist.'. Nothing has been changed in the Azure Storage Account, the network we use is the same, and so the SAS. What could be the reason?
The issue was caused by the presence of
&inside the SAS in the legacy project. The legacy code usedcscfgfiles, since the old Azure Cloud Services technology was used. The new one, instead, usesappsettings.jsonand the new .NET Worker Services template. In this case, to read the configuration, I made it work removing the&.