iOS - Create Container on a Blob Storage problem RRS feed

  • Question

  • Hi,

    I'm adding a storage system on an iOS app that is already available on the app store. I'm following the examples of the docs https://docs.microsoft.com/en-us/azure/storage/storage-ios-how-to-use-blob-storage. When I create a container the function createContainer{} with the sharedKey method works fine, but it doesn't work when I'm using the SAS method.

    I'm programming in Objective c and this is the code with my SAS generated with the Microsoft Azure Storage Explorer software (the same with the Portal method),

        NSError *accountCreationError;
        // Create a storage account object from a connection string.
        AZSCloudStorageAccount *account = [AZSCloudStorageAccount accountFromConnectionString:@"SharedAccessSignature=sv=2015-12-11&ss=bfqt&srt=sco&sp=rwdlacup&st=2017-01-03T19%3A49%3A00Z&se=2017-01-04T19%3A49%3A00Z&sig=gzOUJHTPYACS5NwYlk01oWdRSfimvsHgN%2BrBu%2FVEzac%3D;BlobEndpoint=https://provesappstorage.blob.core.windows.net/;FileEndpoint=https://provesappstorage.file.core.windows.net/;QueueEndpoint=https://provesappstorage.queue.core.windows.net/;TableEndpoint=https://provesappstorage.table.core.windows.net/" error:&accountCreationError];
            NSLog(@"Error in creating account.");
        // Create a blob service client object.
        AZSCloudBlobClient *blobClient = [account getBlobClient];
        // Create a local container object.
        AZSCloudBlobContainer *blobContainer = [blobClient containerReferenceFromName:@"newcontainer2"];
        // Create container in your Storage account if the container doesn't already exist
        [blobContainer createContainerIfNotExistsWithCompletionHandler:^(NSError *error, BOOL exists) {
            if (error){
                NSLog(@"\nError in creating container.");
                NSLog(@"\nContainer OK.");

    And this is the error obtained,

    Error Domain=com.Microsoft.AzureStorage.ErrorDomain Code=3 "(null)" UserInfo={RequestResult=<AZSRequestResult: 0x166cce80>, URLResponse=<NSHTTPURLResponse: 0x165c2ad0> { URL: https://provesappstorage.blob.core.windows.net//newcontainer2?srt=sco&se=2017-01-04T19%3A49%3A00Z&sp=rwdlacup&ss=bfqt&sv=2015-12-11&sig=gzOUJHTPYACS5NwYlk01oWdRSfimvsHgN%2BrBu%2FVEzac%3D&api-version=2015-04-05&st=2017-01-03T19%3A49%3A00Z&restype=container } { status code: 400, headers {

        Date = "Wed, 04 Jan 2017 10:29:04 GMT";

        Server = "Microsoft-HTTPAPI/2.0";

        "Transfer-Encoding" = chunked;

        "x-ms-request-id" = "8777fca1-0001-00cf-2475-6672b5000000";

    } }, HTTP Status Code=400, OperationContext=<AZSOperationContext: 0x165b9dd0>}

    Any help will be appreciated,

    Thanks in advance,



    • Moved by Swikruti Bose Wednesday, January 4, 2017 6:21 PM Related to storage
    Wednesday, January 4, 2017 10:40 AM

All replies

  • Hi,

    Thank you for contacting Microsoft forums. We are pleased to answer your query.

    1. Check if there is blob already exists?
    To create a blob container, the command you want to use is:
    azure storage container create "sascontainer"

    Once this command completes successfully, you should be able to see the blob container in the portal.

    Azure Storage Client Library for iOS

    This article will explain you; How to use Blob storage from iOS

    REST API maybe better for iOS  devices. Azure SDK does not have object-c support as good as C# I am afraid. Blob Service REST API

    For more information on: How to use Blob storage from iOS

    You can't do container related operations (with the exception of listing blobs) using Shared Access Signature. You would need to use account key for performing operations on a container. From this page: http://msdn.microsoft.com/en-us/library/azure/jj721951.aspx

    I hope that the reply will assist you in getting your query addressed. In case you require further assistance, please do reply to the thread as we are always available to your queries.

    Sumanth BM

    Wednesday, January 4, 2017 7:31 PM
  • Hi SumanthBM,

    Thanks for your response. I will check it out.



    Saturday, January 7, 2017 10:29 AM