id: load-document-from-azure-blob-storage
url: signature/net/load-document-from-azure-blob-storage
title: How to load a document from Azure Blob Storage
linkTitle: → Amazon Blob
weight: 2
description: “This section explains how to load document from Azure Blob Storage with GroupDocs.Signature API.”
keywords:
productName: GroupDocs.Signature for .NET
toc: True
structuredData:
showOrganization: True
application: name: Signing document loaded from Azure Blob Storage using C# description: Handling Azure Blob Storage documents with C# language by GroupDocs.Signature for .NET APIs
productCode: signature
productPlatform: net
showVideo: True
howTo:
name: How to get and process Azure Blob Storage document via C#
description: Get information about ways of handling documents downloaded from Azure Blob Storage with C#
steps:
- name: Load source document
text: Instantiate CloudBlobContainer object providing account and blob storage data. Download file and save it to stream.
- name: Pass file to Signature.
text: Instantiate Signature object by passing file stream as a constructor parameter.
- name: Provide signing options.
text: Set specific properties of desired SignOptions instance.
- name: Sign source and obtain result
text: Invoke method Sign with passing created options and output file data. You can save signed file using file path or stream.
Following example demonstrates how to process documents from Azure Blob Storage.
publicstaticvoidRun(){stringblobName="sample.docx";stringoutputFilePath="SignedSample";using(Streamstream=DownloadFile(blobName)){using(Signaturesignature=newSignature(stream)){QrCodeSignOptionsoptions=newQrCodeSignOptions("JohnSmith"){EncodeType=QRCodeTypes.QR,Left=100,Top=100};// sign document to filesignature.Sign(outputFilePath,options);}}Console.WriteLine("\nSource document signed successfully.\nFile saved at "+outputFilePath);}publicstaticStreamDownloadFile(stringblobName){CloudBlobContainercontainer=GetContainer();CloudBlobblob=container.GetBlobReference(blobName);MemoryStreammemoryStream=newMemoryStream();blob.DownloadToStream(memoryStream);memoryStream.Position=0;returnmemoryStream;}privatestaticCloudBlobContainerGetContainer(){stringaccountName="***";stringaccountKey="***";stringendpoint=$"https://{accountName}.blob.core.windows.net/";stringcontainerName="***";StorageCredentialsstorageCredentials=newStorageCredentials(accountName,accountKey);CloudStorageAccountcloudStorageAccount=newCloudStorageAccount(storageCredentials,newUri(endpoint),null,null,null);CloudBlobClientcloudBlobClient=cloudStorageAccount.CreateCloudBlobClient();CloudBlobContainercontainer=cloudBlobClient.GetContainerReference(containerName);container.CreateIfNotExists();returncontainer;}
More resources
GitHub Examples
You may easily run the code above and see the feature in action in our GitHub examples: