Overview

Microsoft Azure is a public cloud computing and enterprise grade platform. Microsoft has started to support PHP as well, so we can deploy our PHP application on Microsoft Azure very easily.

Blob storage is a service provided by Microsoft Azure, like Amazon S3, offers cheap and secure way to store files. It stores unstructured data as objects/blobs in the cloud which can be accessed by http and https protocol.

You can store any type of data or files, such as text, document, music, video or executables. These blobs can be served directly to browser.

Blobs can be stored under a container, which is associated with your storage account.

Create an Azure account

You can create your Azure account here.
Well, we are discussing how to implement Microsoft Azure Blob Storage to your PHP application, so we will stick to that.
Step by step procedure can be found here.

Let’s start

You need composer to install PHP SDK for Blob storage.

  • Install PHP SDK
  • add below content to your composer.json file.

  • Now open command propmt and execute following code
  • php composer install

  • Require the autoloader file, to use Blob Storage apis
  • If you are using using laravel, you can directly use the namespace.

  • Setup Azure storage connection
  • You can find your account key and account name in Azure portal.

  • Create a container
  • Container name must be in lower case. Container name must be start with letter or number.
    Only single dash “-” is allowed in between the letters and numbers.

  • Upload a blob into a container
  • List all blobs in a container
  • Show an image from blob storage
  • I hope you learnt how to implement Microsoft Azure Blob Storage in your PHP application.
    Let me know if you have any queries.