{"id":623,"date":"2011-03-12T02:00:00","date_gmt":"2011-03-12T02:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/cesardelatorre\/2011\/03\/12\/typical-issueone-of-the-request-inputs-is-not-valid-when-working-with-the-windows-azure-development-storage\/"},"modified":"2011-03-12T02:00:00","modified_gmt":"2011-03-12T02:00:00","slug":"typical-issueone-of-the-request-inputs-is-not-valid-when-working-with-the-windows-azure-development-storage","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/typical-issueone-of-the-request-inputs-is-not-valid-when-working-with-the-windows-azure-development-storage\/","title":{"rendered":"Typical issue\u2018One of the request inputs is not valid\u2019 when Working with the Windows Azure Development Storage"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p>One of the typical issues is <strong>getting the error &#8220;One of the request inputs is not valid&#8221; that occurs when testing the application with empty tables in development storage<\/strong>. This is because Development Storage currently requires the schema for an entity stored in a table to have been previously defined before you are allowed to query it.<\/p>\n<p><em>WORKAROUND<\/em><\/p>\n<p>The workaround is simple, we just need to insert, and then delete, a dummy row into the Windows Azure tables if the application is running in the development fabric. During the initialization of the web role, it is a good idea if the application checks whether it is running against local development storage, and if this is the case, it adds, and then deletes, a dummy record to the application&#8217;s Windows Azure tables (It will be done just the first time, per Entity, when working against the Development Storage).<\/p>\n<p>That code can be added using an extension method, for instance.<\/p>\n<p>Here you have extended info about it:<\/p>\n<p><a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ff803365.aspx\">http:\/\/msdn.microsoft.com\/en-us\/library\/ff803365.aspx<\/a><\/p>\n<h5>Working with Development Storage (Taken from the above URL)<\/h5>\n<p>There are some differences between development table storage and Windows Azure table storage documented at <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/dd320275.aspx\">http:\/\/msdn.microsoft.com\/en-us\/library\/dd320275.aspx<\/a>. The team at Adatum encountered the error &#8220;One of the request inputs is not valid&#8221; that occurs when testing the application with empty tables in development storage. The solution that Adatum adopted was to insert, and then delete, a dummy row into the Windows Azure tables if the application is running in the development fabric. During the initialization of the web role, the application calls the <strong>CreateTableIfNotExist&lt;T&gt;<\/strong> extension method in the <strong>TableStorageExtensionMethods <\/strong>class to check whether it is running against local development storage, and if this is the case, it adds, and then deletes, a dummy record to the application&#8217;s Windows Azure tables.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/Hash\/030c41d9079671d09a62d8e2c1db6973.gif\" alt=\"Ff803365.note(en-us,PandP.10).gif\" title=\"Ff803365.note(en-us,PandP.10).gif\" \/>Note:<\/p>\n<p>Don&#8217;t assume that local development storage will work in exactly the same way as Windows Azure storage.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/dynimg\/IC417490.png\" alt=\"Ff803365.bubble(en-us,PandP.10).png\" title=\"Ff803365.bubble(en-us,PandP.10).png\" \/>Markus says:<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/i.msdn.microsoft.com\/dynimg\/IC417494.png\" alt=\"Markus\" title=\"Markus\" \/> You should consider adding dummy records to all tables in local development storage.<\/p>\n<p>The following code from the <strong>TableStorageExtensionMethods <\/strong>class demonstrates how the aExpense application determines whether it is using development storage and how it adds and deletes a dummy record to the table.<\/p>\n<pre>public static bool CreateTableIfNotExist&lt;T&gt;(\n    this CloudTableClient tableStorage, string entityName)\n    where T : TableServiceEntity, new()\n{\n    bool result = tableStorage.CreateTableIfNotExist(entityName);\n\n    \/\/ Execute conditionally for development storage only\n    if (tableStorage.BaseUri.IsLoopback)\n    {\n        InitializeTableSchemaFromEntity(tableStorage,\n            entityName, new T());\n    }\n    return result;\n}\n\nprivate static void InitializeTableSchemaFromEntity(\n    CloudTableClient tableStorage, string entityName,\n    TableServiceEntity entity)\n{\n    TableServiceContext context =\n        tableStorage.GetDataServiceContext();\n    DateTime now = DateTime.UtcNow;\n    entity.PartitionKey = Guid.NewGuid().ToString();\n    entity.RowKey = Guid.NewGuid().ToString();\n    Array.ForEach(\n        entity.GetType().GetProperties(BindingFlags.Public | \n        BindingFlags.Instance),\n        p =&gt;\n        {\n            if ((p.Name != \"PartitionKey\") &amp;&amp;\n                (p.Name != \"RowKey\") &amp;&amp; (p.Name != \"Timestamp\"))\n            {\n               if (p.PropertyType == typeof(string))\n               {\n                   p.SetValue(entity, Guid.NewGuid().ToString(),\n                       null);\n               }\n               else if (p.PropertyType == typeof(DateTime))\n               {\n                   p.SetValue(entity, now, null);\n               }\n           }\n       });\n\n    context.AddObject(entityName, entity);\n    context.SaveChangesWithRetries();\n    context.DeleteObject(entity);\n    context.SaveChangesWithRetries();\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; One of the typical issues is getting the error &#8220;One of the request inputs is not valid&#8221; that occurs when testing the application with empty tables in development storage. This is because Development Storage currently requires the schema for an entity stored in a table to have been previously defined before you are allowed [&hellip;]<\/p>\n","protected":false},"author":362,"featured_media":12806,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[24],"class_list":["post-623","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cesardelatorre","tag-windows-azure"],"acf":[],"blog_post_summary":"<p>&nbsp; One of the typical issues is getting the error &#8220;One of the request inputs is not valid&#8221; that occurs when testing the application with empty tables in development storage. This is because Development Storage currently requires the schema for an entity stored in a table to have been previously defined before you are allowed [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/posts\/623","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/users\/362"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/comments?post=623"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/posts\/623\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/media\/12806"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/media?parent=623"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/categories?post=623"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/tags?post=623"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}