VB.net code to create a blob container if it doesnot exist

Posted by Rajnilari2015 under Azure category on | Points: 40 | Views : 1294
The below code will do so

Public Function GetCloudBlobContainer(connectionString As String, containerName As String) As CloudBlobContainer
Dim storageAccount As CloudStorageAccount = CloudStorageAccount.Parse(connectionString)
Dim blobclient As CloudBlobClient = storageAccount.CreateCloudBlobClient()
Dim blobcontainer As CloudBlobContainer = blobclient.GetContainerReference(containerName)

If blobcontainer.CreateIfNotExists() Then
blobcontainer.SetPermissions(New BlobContainerPermissions() With { _
Key .PublicAccess = BlobContainerPublicAccessType.Blob _
End If
Return blobcontainer
End Function

Comments or Responses

Login to post response