locked
Azure Storage Connection Failed from Emulator and Web Role - Works well with Console Application RRS feed

  • Question

  • var
    
    
     storageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName="
    
    
     + model.AccountName + ";AccountKey="
    
     + model.AccountKey);
    var
    
    
     blobClient = storageAccount.CreateCloudBlobClient();
    var
    
    
     permissions = new
    
    
     BlobContainerPermissions();
    permissions.PublicAccess = BlobContainerPublicAccessType.Container;
    var
    
    
     blobContainer = blobClient.GetContainerReference("container1"
    
    
    );
    blobContainer.CreateIfNotExist();
    

    The above code block works well when run from a console application but fails in azure and local emulator environment. Any clues if anything different that needs to be implemented? Wierd thing is that even on a normal web application it works but not on a web role with cloud as startup project :'(

     

    The Error received is "No connection could be made because the target machine actively refused it. AzureStorageIP:PortNumber"

    Been trying to solve this for last 3 days but no dice. Any hint/clue/help is appreciated.

     

    Thanks,

    Jay
    Monday, February 7, 2011 2:32 PM

Answers

  • Jay and I are working offline.  For those who are following along at home, Jay's solution works fine on my machine...
    • Marked as answer by Mog Liang Monday, February 14, 2011 9:39 AM
    Tuesday, February 8, 2011 4:29 AM

All replies

  • Where does model.AccountName come from?  Are you sure it has the right value when you run under the compute emulator?  (Have you verified by stepping through in the debugger?)
    Monday, February 7, 2011 4:55 PM
  • Hi Steve,

    The values are all hard coded...in the example posted, the model is a static class and account key/name are both constants.  I tried using fiddler to capture the requests and when run as a web app/console, a CONNECT request is made but when using emulator there's no request at all. I assumed it to be an internal issue and deployed the same code to production.  No dice there as well. Something seems to be missing when run in an azure environment :(


    Thanks, Jay
    Tuesday, February 8, 2011 2:43 AM
  • I'm with Steve and think you should verify that the CloudStorageAccount is correctly constructed with valid values for account and key. I would also verify that the endpoints are correct with a location that matches the account and key used.
    Tuesday, February 8, 2011 3:09 AM
    Answerer
  • Hi Neil,

     

    Double checked after Steve's post...infact made the CloudStorageAccount Initialization as below:-

    var storageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=myname;AccountKey=mykey"); 
    
    var blobClient = storageAccount.CreateCloudBlobClient();
    
    var permissions = new BlobContainerPermissions();
    
    permissions.PublicAccess = BlobContainerPublicAccessType.Container;
    
    var blobContainer = blobClient.GetContainerReference("container1");
    
    blobContainer.CreateIfNotExist();
    
    

    Moved the key and name directly to the C# code. Works in console, asp.net but fails in web role. Dint create any new endpoints or enabled CDN.

     


    Thanks, Jay
    Tuesday, February 8, 2011 3:15 AM
  • Any chance you can share the code so I can take a look?  (Steve.Marx@microsoft.com)

    It's hard to argue with the above code, so my only guess is that there's something else strange in the code...

    Have you tried creating a brand new Windows Azure app with a web role and pasting this code in?

    Tuesday, February 8, 2011 3:25 AM
  • I'll zip the solution and would send it across to your email ID.

    Azure SDK Version 1.3.20121.1237


    Thanks, Jay
    Tuesday, February 8, 2011 3:39 AM
  • Jay and I are working offline.  For those who are following along at home, Jay's solution works fine on my machine...
    • Marked as answer by Mog Liang Monday, February 14, 2011 9:39 AM
    Tuesday, February 8, 2011 4:29 AM
  • Hi Steve,

     

    We deployed the sample to Azure and it worked. I think its time for a machine reformat :) thanks for all the help.

     

    Cheers,

    Jay


    Thanks, Jay
    Wednesday, February 9, 2011 2:42 PM