How can I allow Azure OpenAI to access a private Blob specified in image_url?

Riley Sanders 0 Reputation points
2024-10-21T22:52:40.3733333+00:00

I am building an OCR tool that requires interacting with the Azure Open AI API. I have a line of code similar to the following in Python that calls the API of my Open AI resource:

response =

Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
{count} votes

1 answer

Sort by: Most helpful
  1. navba-MSFT 27,605 Reputation points Microsoft Employee Moderator
    2024-10-22T04:11:01.4466667+00:00

    @Riley Sanders Welcome to Microsoft Q&A Forum, Thank you for posting your query here!

    .

    Action Plan:

    Within your image_url attribute if you are hardcoding the image url from the Azure Blob storage, then you need to ensure that you provide the SAS token of the complete blob url as shown below. This is required because, your container is set as private.

    User's image

    Sample SAS token would look like below:

    https://XXXXXXXXX.blob.core.windows.net/XXXXXXX/SHS.jpg?sp=r&st=2024-10-22T04:08:36Z&se=2024-10-22T12:08:36Z&spr=https&sv=2022-11-02&sr=b&sig=HbkIs36dyabgmP3D8aeXKsVRNI03MOpac6QY6ajdRrU%3D

    .

    .

    Answer:

    To answer your question about using managed identity, this can be used if you don't want to provide the SAS token.

    In that case, you first need to update your code to use the Initialize Blob Service Client with Managed Identity, Download Blob as Base64 and then Pass Base64 Encoded Image to GPT-4o.

    The same code is provided here, for your reference.

    .

    .

    Hope this helps. If you have any follow-up questions, please let me know. I would be happy to help.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.