Scanning an Azure Blob for Viruses in PHP

Cloudmersive
2 min readJan 11, 2021

--

Worried about the security of your cloud storage content? You’re not alone. Due to the complicated nature of maintaining privacy and data protection in the cloud vs. on premises, privacy and security are two of the biggest concerns when it comes to the cloud. Fortunately, the following API can assist with this concern by scanning a single Azure Blob file and its contents for viruses. This solution will leverage high-performance scanning capabilities to review a continuously updated collection of virus signatures, malware, ransomware, and other threats.

First, you will need to install the SDK:

composer require cloudmersive/cloudmersive_virusscan_api_client

Then, you’re ready to call the function with the following code:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure API key authorization: Apikey
$config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('Apikey', 'YOUR_API_KEY');
$apiInstance = new Swagger\Client\Api\ScanCloudStorageApi(


new GuzzleHttp\Client(),
$config
);
$connection_string = "connection_string_example"; // string | Connection string for the Azure Blob Storage Account; you can get this connection string from the Access Keys tab of the Storage Account blade in the Azure Portal.
$container_name = "container_name_example"; // string | Name of the Blob container within the Azure Blob Storage account
$blob_path = "blob_path_example"; // string | Path to the blob within the container, such as 'hello.pdf' or '/folder/subfolder/world.pdf'
try {
$result = $apiInstance->scanCloudStorageScanAzureBlob($connection_string, $container_name, $blob_path);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling ScanCloudStorageApi->scanCloudStorageScanAzureBlob: ', $e->getMessage(), PHP_EOL;
}
?>

Now you will be able to identify the virus name if one is present; if the file is clean, then no further action is needed. Head to the Cloudmersive website to gain access to your free API key, as well as 800 calls/month across our extensive selection of APIs.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

No responses yet