3
votes

The Problem

When I try to work with the storage emulator (v3.4.0.0), I receive the following exception:

System.Net.WebException: The remote server returned an error: (404) Not Found.

Specifically, this happens when I attempt to interact with my CloudBlobContainer instance, which was created via blobClient.GetContainerReference( myContainerName ). In this case, it's happening when I try the following:

var permissions = await container.GetPermissionsAsync();

When I debug the code and watch the container instance before this line is executed, I can see that the object's internals are indeed set to be using the emulator and that all of the appropriate fields/properties are as they should be (using the correct "devstoreaccount1" account name and so on).

Any idea why this is happening? Even better: how can I get my code to see the emulator?

Additional Info

  • The storage emulator is running, I've set it to use my local Sql Server 2012 instance and can confirm that it has created all of the appropriate tables in the database.
  • I tried pinging 127.0.0.1:10000 but get the message "Ping request could not find host 127.0.0.1:10000. Please check the name and try again."
  • I have a local instance of IIS 8.5 running as well, though I guess that's not the problem. Regardless, I'm running my app through IIS, so turning it off isn't an option for me.
  • Running on Windows 8.1
2

2 Answers

8
votes

The problem wasn't with the emulator itself, it was with the code. Though I didn't see anything in the docs I read to explain this, it seems that it was necessary to call await container.CreateIfNotExistsAsync() before interacting with the container object.

I assume this is because it has to physically create the container before applying any settings to it.

1
votes

If the container doesn't exist then both the emulator and the storage service would return a 404. That being said - you don't have to call CreateIfNotExists before any container operation - that could be very inefficient. Depending on what your scenario is you have a couple of different approaches. You could create an initialization job that initializes your environment creating all resources that your application is dependent on. Or alternatively, if it is likely that the container will not exist (eg - if you are creating them dynamically) then you can easily have your application handle a 404 and then create the container at that point.