title: Best Practice accessing Azure Blob Images in Python
body: <p>I am currently working on an AI webpage that enables users to upload datasets and do all kinds of stuff with that data in the cloud. I am using a react frontend with a django backend linked to a PostgreSQL and a blob storage on Azure.</p>
  <p>Now my question is:</p>
  <p>What is the common way to efficiently get the images as arrays from the blob storage into my django backend to run further python scripts (like augmentation) on them, while using my database models (so not by directly connecting to the blob storage)?</p>
  <p>This line of code works to retrieve the images from blob using the url that was saved in my database and perform a simple rotation. But the &quot;request.urlopen&quot; takes very very long. There must be a better way...</p>
  <pre><code>class Image(models.Model):
      name = models.CharField(default='', max_length=100)
      image = models.FileField(upload_to='data', default='')
      dataset = models.ForeignKey(Dataset, on_delete=models.CASCADE)
  
  img = Image.objects.filter(dataset=somedataset, user=someuser)
  im = np.rot90(np.asarray(Image.open(BytesIO(request.urlopen(img['image']).read()))))
  </code></pre>