%3CLINGO-SUB%20id%3D%22lingo-sub-774784%22%20slang%3D%22en-US%22%3EXmlException%3A%20Root%20element%20is%20missing%20while%20performing%20PUT%20operation%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-774784%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSTRONG%3E%3CU%3EScenario%3C%2FU%3E%3C%2FSTRONG%3E%3CSTRONG%3E%3A%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EWhile%20invoking%20a%20REST%20API%20to%20perform%20PUT%20message%20to%20add%20a%20message%20to%20the%20Azure%20Queue%20storage%2C%20I%20was%20getting%20the%20below%20exception%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CTABLE%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22677%22%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3EMicrosoft.WindowsAzure.Storage.StorageException%20occurred%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3EHResult%3D0x80131500%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3EMessage%3DRoot%20element%20is%20missing.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3ESource%3D%3CCANNOT%20evaluate%3D%22%22%20the%3D%22%22%20exception%3D%22%22%20source%3D%22%22%3E%3C%2FCANNOT%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3EStackTrace%3A%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3E%26nbsp%3B%26nbsp%3B%20at%20Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync%5BT%5D(RESTCommand%601%20cmd%2C%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20IRetryPolicy%20policy%2C%20OperationContext%20operationContext)%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3E%26nbsp%3B%26nbsp%3B%20at%20Microsoft.WindowsAzure.Storage.Queue.CloudQueue.AddMessage(CloudQueueMessage%20message%2C%20Nullable%601%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20timeToLive%2C%20Nullable%601%20initialVisibilityDelay%2C%20QueueRequestOptions%20options%2C%20OperationContext%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20operationContext)%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3E%26nbsp%3B%26nbsp%3B%20at%20QueueSASSender.Program.Main(String%5B%5D%20args)%20in%20E%3A%5CCxfiles%5C117092716404612%5C2017-11-%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%2003%5CQueueSASSender%5CQueueSASSender%5CProgram.cs%3Aline%2041%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3EInner%20Exception%201%3A%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3EXmlException%3A%20Root%20element%20is%20missing.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EMy%20sample%20code%20was%20as%20shown%20below%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CTABLE%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTD%20width%3D%22670%22%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3Evar%20queueClient%20%3D%26nbsp%3B%26nbsp%3B%20new%20CloudQueueClient(new%20Uri(%22https%3A%2F%2F*****.queue.core.windows.net%3A443%2F%22)%2C%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20new%20StorageCredentials(%22%3Fst%3D2018-11-27T23%253A22%253A00Z%26amp%3Bse%3D2020-12-%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%2030T23%253A22%253A00Z%26amp%3Bsp%3Draup%26amp%3Bsv%3D2012-02-%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%2012%26amp%3Bsig%3DVBzLT2lPg7********************%252BI%253D%22))%3B%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3Evar%20queue%20%3D%20queueClient.GetQueueReference(%22myqueue%22)%3B%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3Equeue.AddMessage(new%20CloudQueueMessage(%22my%20message%22))%3B%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CU%3ECause%3A%3C%2FU%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EI%20started%20my%20investigation%20with%20the%20SAS%20Token%20which%20was%20in%20the%20below%20format%3A%3C%2FP%3E%0A%3CP%3Esv%3D2012-02-12%26amp%3Bsi%3D****%26amp%3Bsig%3DcD7NF1cCra01Wj8mIid%25*********gOVA9VVsbQg%253D%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20one%20that%20grabbed%20my%20attention%20was%20%E2%80%98%3CSTRONG%3Esv%3C%2FSTRONG%3E%E2%80%99%20(Service%20Version).%20I%20could%20see%20that%20I%20was%20using%20an%20older%20version%20to%20formulate%20the%20token%20(sv%3D2012-02-12).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20tried%20to%20compose%20the%20request%20again%20and%20confirmed%20if%20that%20was%20indeed%20the%20cause%20of%20this%20issue.%20I%20created%20a%20new%20SAS%20token%20using%20a%20different%20version%20of%20the%20sv%20(Service%20Version)%2C%20though%20not%20the%20most%20recent%20one.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EBelow%20is%20my%20new%20SAS%20token%3A%3C%2FP%3E%0A%3CP%3Est%3D2018-11-27T23%253A22%253A00Z%26amp%3Bse%3D2020-12-30T23%253A22%253A00Z%26amp%3Bsp%3Draup%26amp%3B%3CSTRONG%3Esv%3D2017-04-17%3C%2FSTRONG%3E%26amp%3Bsig%3DVBzLT2lPg7jwT5***********%252BI%253D%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CU%3E%3CSPAN%3EResolution%3A%3C%2FSPAN%3E%3C%2FU%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EI%20have%20referred%20to%20the%20%3CSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Frest%2Fapi%2Fstorageservices%2Fput-message%23response%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Edocument%3C%2FA%3E%3C%2FSPAN%3Ewhich%20says%20the%20new%20SDK%20is%20expecting%20the%20Put%20Message%20API%20call%20to%20return%20a%20valid%20XML%20response.%20Since%20the%20SAS%20signature%20had%20an%20older%20version%20no%20response%20was%20returned%20from%20the%20Azure%20Queue%20Storage.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F124591i20E4212E479AECDD%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Capture.PNG%22%20title%3D%22Capture.PNG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAlso%20note%20that%20the%20message%20was%20getting%20added%20in%20the%20queue%20though%20we%20got%20the%20exception%20in%20the%20response.%20A%20workaround%20may%20be%20to%20simply%20ignore%20the%20storage%20exception%20generated%20by%20this%20API%2C%20but%20this%20carries%20risk%20as%20you%20may%20be%20ignoring%20genuine%20exceptions%20too.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20strongly%20recommend%20that%20you%20regenerate%20the%20SAS%20signature%20to%20allow%20you%20to%20take%20advantage%20of%20all%20the%20features%20that%20have%20been%20added%20over%20the%20years%20to%20the%20Azure%20Storage%20SDK.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHope%20this%20helps.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3Asmiling_face_with_smiling_eyes%3A%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-774784%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EXmlException%3A%20Root%20element%20is%20missing%20while%20performing%20PUT%20operation%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

Scenario:

While invoking a REST API to perform PUT message to add a message to the Azure Queue storage, I was getting the below exception:

 

 

Microsoft.WindowsAzure.Storage.StorageException occurred

HResult=0x80131500

Message=Root element is missing.

Source=<Cannot evaluate the exception source>

StackTrace:

   at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand`1 cmd,

     IRetryPolicy policy, OperationContext operationContext)

   at Microsoft.WindowsAzure.Storage.Queue.CloudQueue.AddMessage(CloudQueueMessage message, Nullable`1

     timeToLive, Nullable`1 initialVisibilityDelay, QueueRequestOptions options, OperationContext

     operationContext)

   at QueueSASSender.Program.Main(String[] args) in E:\Cxfiles\117092716404612\2017-11-

     03\QueueSASSender\QueueSASSender\Program.cs:line 41

 

Inner Exception 1:

XmlException: Root element is missing.

 

 

My sample code was as shown below:

 

 

var queueClient =   new CloudQueueClient(new Uri("https://*****.queue.core.windows.net:443/"),

                   new StorageCredentials("?st=2018-11-27T23%3A22%3A00Z&se=2020-12-

                   30T23%3A22%3A00Z&sp=raup&sv=2012-02-                

                   12&sig=VBzLT2lPg7********************%2BI%3D"));

 

var queue = queueClient.GetQueueReference("myqueue");

queue.AddMessage(new CloudQueueMessage("my message"));

 

 

Cause:

I started my investigation with the SAS Token which was in the below format:

sv=2012-02-12&si=****&sig=cD7NF1cCra01Wj8mIid%*********gOVA9VVsbQg%3D

 

The one that grabbed my attention was ‘sv’ (Service Version). I could see that I was using an older version to formulate the token (sv=2012-02-12).

 

I tried to compose the request again and confirmed if that was indeed the cause of this issue. I created a new SAS token using a different version of the sv (Service Version), though not the most recent one.

 

Below is my new SAS token:

st=2018-11-27T23%3A22%3A00Z&se=2020-12-30T23%3A22%3A00Z&sp=raup&sv=2017-04-17&sig=VBzLT2lPg7jwT5***********%2BI%3D

 

Resolution:

I have referred to the document which says the new SDK is expecting the Put Message API call to return a valid XML response. Since the SAS signature had an older version no response was returned from the Azure Queue Storage.

 

Capture.PNG

 

Also note that the message was getting added in the queue though we got the exception in the response. A workaround may be to simply ignore the storage exception generated by this API, but this carries risk as you may be ignoring genuine exceptions too.

 

We strongly recommend that you regenerate the SAS signature to allow you to take advantage of all the features that have been added over the years to the Azure Storage SDK.

 

Hope this helps.

 

:smiling_face_with_smiling_eyes: