Scan an Azure Blob for Viruses in Swift

If you’ve trusted an Azure Blob cloud storage container with sensitive data, you want solid confirmation that the contents are completely safe. By utilizing the following API in Swift, you will be able to automatically scan an Azure Blob and its contents for multiple threats, including viruses, malware, trojans, ransomware, and spyware. The API leverages a database of over 17 million virus signatures that are continuously updated in the cloud to provide the most current and reliable protection for you and your customer’s information.

To ensure the process runs smoothly, you will need to input the Azure Blob storage account connection string, Blob container name, Blob container path, and your API key into the following code:

import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
var semaphore = DispatchSemaphore (value: 0)var request = URLRequest(url: URL(string: "")!,timeoutInterval: Double.infinity)
request.addValue("<string>", forHTTPHeaderField: "connectionString")
request.addValue("<string>", forHTTPHeaderField: "containerName")
request.addValue("<string>", forHTTPHeaderField: "blobPath")
request.addValue("YOUR-API-KEY-HERE", forHTTPHeaderField: "Apikey")
request.httpMethod = "POST"let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data else {
print(String(describing: error))
print(String(data: data, encoding: .utf8)!)

You results will be returned immediately, allowing you to determine if any of your files have been contaminated and need attention. To retrieve your API key, head to the Cloudmersive website to register for a free account; this provides access to 800 monthly calls across our API library as well.

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