How to Scan an Azure Blob for Viruses in Python
Cyberspace can be a dangerous place, and if you’re utilizing an Azure Blob for storage, you want to make sure the contents are virus-free; once a virus infiltrates cloud storage, it may unexpectedly flow into various business critical applications or be downloaded by business users. The following API provides multi-threat scanning in Python for a single Azure Blob and its contents, so you can rest assured that your storage is safe. The high speed in-memory scanning delivers a subsecond response time for a variety of file formats (Office, PDF, HTML, and Flash) and Zip support (.Zip, .Rar, .DMG, .Tar, and other archive formats).
To use this Cloudmersive API, run this command to install the SDK:
pip install cloudmersive-virus-api-client
Next, you can call the function using the following code:
from __future__ import print_function
import time
import cloudmersive_virus_api_client
from cloudmersive_virus_api_client.rest import ApiException
from pprint import pprint# Configure API key authorization: Apikey
configuration = cloudmersive_virus_api_client.Configuration()
configuration.api_key['Apikey'] = 'YOUR_API_KEY'# create an instance of the API class
api_instance = cloudmersive_virus_api_client.ScanCloudStorageApi(cloudmersive_virus_api_client.ApiClient(configuration))
connection_string = 'connection_string_example' # str | 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' # str | Name of the Blob container within the Azure Blob Storage account
blob_path = 'blob_path_example' # str | Path to the blob within the container, such as 'hello.pdf' or '/folder/subfolder/world.pdf'try:
# Scan an Azure Blob for viruses
api_response = api_instance.scan_cloud_storage_scan_azure_blob(connection_string, container_name, blob_path)
pprint(api_response)
except ApiException as e:
print("Exception when calling ScanCloudStorageApi->scan_cloud_storage_scan_azure_blob: %s\n" % e)
This will return a lightning-fast result indicating if your Azure blob is free from viruses, malware, trojans, ransomware, and spyware. If a threat is found, the API will indicate which virus it is, enabling you to address it immediately. You can retrieve the free API Key from our Cloudmersive website, which will also give you access to 800 monthly calls from our variety of APIs.