How to Check an Azure Blob for Viruses in Go

Cloudmersive
2 min readMay 10, 2021

--

With cyberattacks increasing in number and ingenuity every day, any application or database could become a potential target. Even cloud storage containers such as the Azure Blob are susceptible to infiltration by malicious content. To ensure your cloud data doesn’t fall prey to these cyber predators, you can utilize the following API in Go to scan an Azure Blob and its contents for viruses, malware, trojans, ransomware, and spyware. The function provides wide file format support ranging from common Office and PDF documents to more complex Zip and archive formats, ensuring that no document is left unchecked.

We will first gather the connection string, Blob container name, and Blob container path from Azure, and then we can plug it into the following code to call the function:

package mainimport (
"fmt"
"net/http"
"io/ioutil"
)
func main() {url := "https://api.cloudmersive.com/virus/scan/cloud-storage/azure-blob/single"
method := "POST"
client := &http.Client {
}
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("connectionString", "<string>")
req.Header.Add("containerName", "<string>")
req.Header.Add("blobPath", "<string>")
req.Header.Add("Apikey", "YOUR-API-KEY-HERE")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}

If you need to retrieve an API key, you can do so by visiting the Cloudmersive website and registering for a free account; this provides access to 800 calls/month across our wide array 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