Check an Azure Blob for Viruses in C/C++

Utilizing an Azure Blob for cloud storage is a great way to conserve space on your system while maintaining compliance requirements. However, even though an Azure Blob is supported by Microsoft’s security, it is still possible for infected files to make their way into your storage container and corrupt your valid documents and files. To provide an additional layer of protection and peace of mind, we will demonstrate how you can use the following API in C/C++ to automatically scan an Azure Blob and its contents for threats.

We will begin by installing libcurl into our project:

libcurl/7.75.0

Now we are ready to call the virus scan function with the following code:

CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curl, CURLOPT_URL, "https://api.cloudmersive.com/virus/scan/cloud-storage/azure-blob/single");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "connectionString: <string>");
headers = curl_slist_append(headers, "containerName: <string>");
headers = curl_slist_append(headers, "blobPath: <string>");
headers = curl_slist_append(headers, "Apikey: YOUR-API-KEY-HERE");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
res = curl_easy_perform(curl);
}
curl_easy_cleanup(curl);

Successful delivery of your results will specify the virus name and affected file (if any) in no time at all. Visit the Cloudmersive website to obtain your API key by registering for a free account; this provide access to 800 calls/month across our library of APIs.