I am trying to create a blob container with a name based on a value (AssetID) passed into the function as a parameter.
public CloudBlobContainer GetCloudBlobContainer(int id)
{
// Retrieve storage account from connection-string
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["StorageConnection"].ConnectionString);
// Create the blob client
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
// Retrieve a reference to a container
CloudBlobContainer blobContainer = blobClient.GetContainerReference("AssetDocs" + id);
try
{
// Create the container if it doesn't already exist
if (blobContainer.CreateIfNotExist())
{
blobContainer.SetPermissions(
new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Blob }
);
}
}
catch (WebException e)
{
return blobContainer;
}
return blobContainer;
}
When I run the code I get the following exception:
An exception of type 'Microsoft.WindowsAzure.StorageClient.StorageClientException' occurred in Microsoft.WindowsAzure.StorageClient.dll but was not handled in user code
Additional information: One of the request inputs is out of range.
I tried to add a try...catch however this does not seem to trap the exception so I can find more details.
If tried adding id.ToString() and also removing id altogether but that didn't work either.
What am I doing wrong?