Failing to create blob container from my C# program while using Access Key Connection string.

JSlaby 26 Reputation points
2021-11-15T07:03:08.393+00:00

I started exploring Azure. I set up my Azure account, Resource group, created storage account. I try to create Blob container from my C# program:
I am using 'Connection string' from Storage account Access key to access the Storage account and create the blob container and upload some files.

1.CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["StorageConnectionString"]);

2.CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

3.CloudBlobContainer container = blobClient.GetContainerReference("whatever");

4.if (container.CreateIfNotExists()) {}

The program fails on the 4th line giving me error: The remote server returned an error: (400) Bad Request.
Could someone help me to pass through that? Is it firewall?

Azure Key Vault
Azure Key Vault
An Azure service that is used to manage and protect cryptographic keys and other secrets used by cloud apps and services.
1,257 questions
Azure Container Instances
Azure Container Instances
An Azure service that provides customers with a serverless container experience.
690 questions
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,787 questions
0 comments No comments
{count} votes

Accepted answer
  1. Jaliya Udagedara 2,821 Reputation points MVP
    2021-11-15T21:14:19.633+00:00

    Please follow this approach:
    https://video2.skills-academy.com/en-us/azure/storage/blobs/storage-quickstart-blobs-dotnet

       // Create a BlobServiceClient object which will be used to create a container client  
       BlobServiceClient blobServiceClient = new BlobServiceClient(connectionString);  
         
       //Create a unique name for the container  
       string containerName = "quickstartblobs" + Guid.NewGuid().ToString();  
         
       // Create the container and return a container client object  
       BlobContainerClient containerClient = await blobServiceClient.CreateBlobContainerAsync(containerName);  
    

2 additional answers

Sort by: Most helpful
  1. JSlaby 26 Reputation points
    2021-11-16T02:09:52.017+00:00

    Thank you for your reply.
    Perhaps that solution would work in some other environment than mine.
    For the time being I am getting the following exception:
    Perhaps I need to install the right TLS (whatever it is).

    RequestId:a6fda97d-001e-0066-048e-da357c000000
    Time:2021-11-16T02:07:32.5910036Z
    Status: 400 (The TLS version of the connection is not permitted on this storage
    account.)
    ErrorCode: TlsVersionNotPermitted

    Content:
    <?xml version="1.0" encoding="utf-8"?><Error><Code>TlsVersionNotPermitted</Code>
    <Message>The TLS version of the connection is not permitted on this storage acco
    unt.
    RequestId:a6fda97d-001e-0066-048e-da357c000000
    Time:2021-11-16T02:07:32.5910036Z</Message></Error>

    Headers:
    x-ms-request-id: a6fda97d-001e-0066-048e-da357c000000
    x-ms-client-request-id: b996629f-a7fa-4e5c-8b03-859b83a763b0
    x-ms-error-code: TlsVersionNotPermitted
    Connection: close
    Content-Length: 266
    Content-Type: application/xml
    Date: Tue, 16 Nov 2021 02:07:32 GMT
    Server: Microsoft-HTTPAPI/2.0

    Press enter to exit.

    Thanks a lot


  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.