Block storage reference in SQL azure

I'm just wondering if it is possible to reference azure blob storage data in a column of an Azure SQL table?

For example, let's say I have a table called "Users" in my Azure SQL database, one of the columns in this table is UserImage , and instead of creating UserImage as varbinary(MAX) and storing the image data directly in the table, I would like to save image data in the blob store, get a link to the blob data and save this link in the UserImage ( varchar ?) column in the database, and then somehow, when reading a row from the Users table, access the associated image data from the blob store, using the link to this data.

I ask this because blob storage is significantly cheaper than binary / blob data directly in SQL Azure.

+6
source share
3 answers

You should be able to save the image URL in SQL Azure and ask the client program to parse the URL and display the image from the URL.

I can’t figure out how SQL Azure can go directly to the Blob repository, and I don’t see the need for this, since most client programs can work with the URL, as well as with BLOB.

+3
source

You just need to save the Url image in SQL Azure, here is a short snippet to upload the image to Blob and get its Url:

 // Fake stream that contains your image to upload Stream data; // Get a handle on account, create a blob service client and get container proxy var container = Account.CreateCloudBlobClient() .GetContainerReference("my-fake-container"); // Create a blob in container and upload image bytes to it var blob = container.GetBlobReference("my-fake-id"); blob.Properties.ContentType = "image/jpeg"; blob.UploadFromStream(data); // Get your iage Url in the Blob storage var imageUrl = blob.Uri; 

Now you just need to save imageUrl in your line.

+4
source

Yes .... You can do this by storing the URL in SQL Azure or elsewhere, and then retrieving the URL and passing it to the blob

 void DoSthWithBlob(Uri blobUri, StorageCredentials credentials){ var blob = new CloudBlob(blobUri, credentials); blob.FetchAttributes(); } 
0
source

Source: https://habr.com/ru/post/905307/


All Articles