none
iOS - Create Container on a Blob Storage problem

    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),

    -(void)createContainer{
        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];
            
        if(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.");
            }else{
                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,

    Bests,

    Juli


    Wednesday, January 4, 2017 10:40 AM

All replies