Need an example for generating SAS token for Blob storage in PHP with REST API

Luca Marchal 20 Reputation points
2024-01-03T12:40:13.9133333+00:00

Hi there,

I have a PHP (Laravel) + React.js (with Intertia) app that I'm building that needs to use Azure Blob Storage for image uploading and serving images. I've successfully built an uploader on the frontend that relies on a SAS token. My intent was to use the Valet Key pattern to generate this SAS token from the PHP backend, and serve it to the frontend when the page is rendered (I'm using Socialite on the PHP / Laravel side for authentication with Entra ID).

Now the PHP storage client libraries are being retired, and we're forced to use the raw REST API, I'm really struggling to generate the SAS key on the server side for my valet key pattern. I haven't been able to find a single example online of someone else who's successfully integrated the REST API.

Really struggling here and could do with some guidance and / or an example.

Thanks,

Luca

Azure Storage
Azure Storage

Globally unique resources that provide access to data management services and serve as the parent namespace for the services.

Azure Blob Storage
Azure Blob Storage

An Azure service that stores unstructured data in the cloud as blobs.

0 comments No comments

Answer accepted by question author
Anand Prakash Yadav 7,875 Reputation points Microsoft External Staff
2024-01-04T11:34:33.72+00:00

Hello Luca Marchal,

Thank you for posting your query here!

The same query has been answered in the following SO thread, please check:

https://stackoverflow.com/questions/77751969/generating-sas-token-for-azure-blob-storage-in-php-with-rest-api

Please let us know if you have any further queries. I’m happy to assist you further.


Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

Was this answer helpful?


1 additional answer

Sort by: Oldest
  1. Brecht Vermeersch 0 Reputation points
    2026-06-30T16:02:13.82+00:00

    There is now a maintained community alternative to the retired Microsoft PHP storage package, so you do not have to hand-build the full Blob REST signing flow unless you want to.

    For PHP applications, especially Laravel valet-key style flows, the practical replacement is azure-oss/storage-blob:

    https://packagist.org/packages/azure-oss/storage-blob

    Docs:

    https://php-oss-for-azure.github.io/storage-blob/core

    Migration guide from the retired package:

    https://php-oss-for-azure.github.io/storage-blob/migrate-from-microsoft-azure-storage-blob

    If the goal is specifically SAS generation from PHP for Blob upload/read flows, I’d recommend pointing people there rather than telling them the only option is raw REST API code.

    Was this answer helpful?

    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.