none
Azure Storage: The value for one of the HTTP headers is not in the correct format

    Question

  • Hi there

    What are the possible reasons for the error "Azure Storage: The value for one of the HTTP headers is not in the correct format".

    I am not using an emulator, and exactly the same code and DLLs will function properly on a server but not on another. The same frameworks and versions are installed on both servers.

    My connection string looks like this:

    "DefaultEndpointsProtocol=https;AccountName=account-name;AccountKey=account-key"

    This is what the exception looks like:

    [Err] 7/3/2015 10:35:44 AM: Exception: Microsoft.WindowsAzure.Storage.StorageException: The remote server returned an error: (400) Bad Request. ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.
       at System.Net.HttpWebRequest.GetResponse()
       at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext)
       --- End of inner exception stack trace ---
       at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext)
       at Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob.AcquireLease(Nullable`1 leaseTime, String proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
       at DAO_GameState.SaveToAzureBlob(DEGameState gameState)
    Request Information
    RequestID:d160523d-0001-0050-557c-b5d9c5000000
    RequestDate:Fri, 03 Jul 2015 10:35:43 GMT
    StatusMessage:The value for one of the HTTP headers is not in the correct format.
    
    Friday, July 3, 2015 11:06 AM

Answers

All replies

  • Hi,

    Re-installing the Azure SDK might fix the issue. 

    Similar issue here, please check if that could be of any help.

    If the above doesn't help, I recommend you to create a support ticket for assistance on the query as this needs access to your PUID information.

    Regards,
    Shirisha Paderu


    Saturday, July 4, 2015 7:47 AM
    Moderator
  • Hi Shirisha

    Many thanks for looking into this. Here is some more information that you may find useful.

    The server where it works is an A0 instance which we use as staging. Now comes the interesting part:

    This morning I captured an image of this A0 instance, and deployed it as an A6 instance. The VM I had tried this out previously was an A7 instance and it also fails in it.

    Here's the code I'm running if you're interested. This runs on an IIS7, and I got the Azure Storage DLL just a few days ago using nuget.

    	static void SaveToAzureBlob(DEGameState gameState)
    	{
    		try
    		{
    			// Start timing
    			Stopwatch sw = Stopwatch.StartNew();
    
    			// Retrieve storage account from connection string.
    			CloudStorageAccount storageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=...;AccountKey=...");
    			
    			// Create the blob client.
    			CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
    
    			// Retrieve a reference to a container.
    			CloudBlobContainer container = blobClient.GetContainerReference("gamestatedev");
    			
    			// Create the container if it doesn't already exist.
    			container.CreateIfNotExists();
    
    			// Retrieve reference to a blob named "myblob".
    			CloudBlockBlob blockBlob = container.GetBlockBlobReference("gs" + gameState.worldId + ".bin");
    
    			// Acquire lease (lock..?)
    			string leaseId = "lease" + gameState.worldId;
    			blockBlob.AcquireLease(new TimeSpan(0,0,30), leaseId);
    			
    			try
    			{
    				byte[] bytes = gameState.ToData().ToBytes();
    				MemoryStream stream = new MemoryStream(bytes);
    				blockBlob.UploadFromStream(stream);
    				stream.Close();
    			}
    			catch (Exception ex)
    			{
    				DEDebug.LogException(ex);
    			}
    			finally
    			{
    				// Can fail here too!
    				blockBlob.ReleaseLease(new AccessCondition {
    					LeaseId = leaseId
    				});
    			}
    
    
    			if (traceAzureStorageTiming)
    			{
    				long timing = sw.ElapsedMilliseconds;
    				DEDebug.LogError("Time to save=" + timing + "ms");
    			}
    		}
    		catch (Exception ex)
    		{
    			DEDebug.LogException(ex);
    		}
    	}

    And here's the stack trace:

    7/4/2015 10:23:36 AM: Exception: Microsoft.WindowsAzure.Storage.StorageException: The remote server returned an error: (400) Bad Request. ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.
       at System.Net.HttpWebRequest.GetResponse()
       at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext)
       --- End of inner exception stack trace ---
       at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext)
       at Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob.AcquireLease(Nullable`1 leaseTime, String proposedLeaseId, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
       at DAO_GameState.SaveToAzureBlob(DEGameState gameState)


    Saturday, July 4, 2015 10:32 AM
  • The problem is with your lease id value. The lease id value should be a GUID (in string format). Please see the documentation here for more details: https://msdn.microsoft.com/en-us/library/azure/ee691972.aspx (Look under Request Headers section, x-ms-lease-id header description.

    Hope this helps.

    Sunday, July 5, 2015 8:32 PM