Introduction
Recently I had to extract files from a .zip file stored on Azure Blob Storage in Azure WebJob process.
The approach
This is what I did from scratch:
Create Non-continuous Azure WebJob
1
2
3
4
5
6
7
8
9
10
11
12
13
14static void Main()
{
var host = new JobHost();
host.Call(typeof(Functions).GetMethod(“MyMethod”));
}
public class Functions
{
[ ]
public static void MyMethod()
{
// code
}
}Install WindowsAzure.ConfigurationManager and WindowsAzure.Storage nuget packages.
1
2Install-Package Microsoft.WindowsAzure.ConfigurationManager
Install-Package WindowsAzure.StorageAdd System.IO.Compression.dll from system dlls.
Add this code:
Important notes
- Previously we need to create Azure Storage Account and get the storageAccountName and storageAccountKey.
- CloudConfigurationManager is able to retrieve settings firdt from Azure WebApp Settings UI and secondly from App.config file.
- We must create a new Blob Container and change in the code (or add a new app setting).
- ZipArchive is the system native approach to unzip files.
- Isn’t needed store temporary files to unzip and I have tested files until 150 MB (10MB compressed) on WebJobs working fine.
All articles in this blog are licensed under CC BY-SA 4.0 unless stating additionally.