Retrieving row from Azure table storage
Trying to handle Azure storage table operations using .net core. I have successfully added a new storage table and inserted the new row with unique rowKey (I tested the insertion with re-insertion which gave me conflict which means it already has a key). When I am trying to retrieve the same key with rowKey =1 which I have inserted then getting an error.
CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(StorageConnectionString);
//create storage table
CreateTable(cloudStorageAccount).GetAwaiter().GetResult();
InsertEntity(cloudStorageAccount).GetAwaiter().GetResult();
RetrieveEntity(cloudStorageAccount, "blog", "1").GetAwaiter().GetResult();
public static async Task RetrieveEntity(CloudStorageAccount cloudStorageAccount,
string partitionKey, string rowKey)
{
var cloudTableClient = cloudStorageAccount.CreateCloudTableClient();
var cloudTableReference = cloudTableClient.GetTableReference("MyAzureTableStorage");
TableOperation retrieve = TableOperation.Retrieve<BlogEntity>(partitionKey, rowKey);
var result = await cloudTableReference.ExecuteAsync(retrieve);
if(result.Result == null)
{
Console.WriteLine("Not able to find the results");
}
else
{
Console.WriteLine($"Blog found for author: {((BlogEntity)result.Result).Author}");
}
}
Getting an error:
Microsoft.WindowsAzure.Storage.StorageException
HResult=0x80131500
Message=No parameterless constructor defined for this object.
Source=Microsoft.WindowsAzure.Storage
StackTrace:
at Microsoft.WindowsAzure.Storage.Core.Executor.Executor. <ExecuteAsyncInternal>d__4`1.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at AzureTable.Program.<RetrieveEntity>d__3.MoveNext() in D:Manish PracticeAzureItAzureTableProgram.cs:line 46
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at AzureTable.Program.Main(String args) in D:ManishPracticeAzureItAzureTableProgram.cs:line 21
Inner Exception 1:
MissingMethodException: No parameterless constructor defined for this object.
BlogEntity class :
public class BlogEntity : TableEntity
{
public BlogEntity(int ID, string author, string title, string description)
{
this.UniqueID = ID;
this.Author = author;
this.Title = title;
this.Description = description;
this.PartitionKey = "blog";
this.RowKey = ID.ToString();
}
public int UniqueID { get; set; }
public string Author { get; set; }
public string Title { get; set; }
public string Description { get; set; }
}
c#



add a comment |
Trying to handle Azure storage table operations using .net core. I have successfully added a new storage table and inserted the new row with unique rowKey (I tested the insertion with re-insertion which gave me conflict which means it already has a key). When I am trying to retrieve the same key with rowKey =1 which I have inserted then getting an error.
CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(StorageConnectionString);
//create storage table
CreateTable(cloudStorageAccount).GetAwaiter().GetResult();
InsertEntity(cloudStorageAccount).GetAwaiter().GetResult();
RetrieveEntity(cloudStorageAccount, "blog", "1").GetAwaiter().GetResult();
public static async Task RetrieveEntity(CloudStorageAccount cloudStorageAccount,
string partitionKey, string rowKey)
{
var cloudTableClient = cloudStorageAccount.CreateCloudTableClient();
var cloudTableReference = cloudTableClient.GetTableReference("MyAzureTableStorage");
TableOperation retrieve = TableOperation.Retrieve<BlogEntity>(partitionKey, rowKey);
var result = await cloudTableReference.ExecuteAsync(retrieve);
if(result.Result == null)
{
Console.WriteLine("Not able to find the results");
}
else
{
Console.WriteLine($"Blog found for author: {((BlogEntity)result.Result).Author}");
}
}
Getting an error:
Microsoft.WindowsAzure.Storage.StorageException
HResult=0x80131500
Message=No parameterless constructor defined for this object.
Source=Microsoft.WindowsAzure.Storage
StackTrace:
at Microsoft.WindowsAzure.Storage.Core.Executor.Executor. <ExecuteAsyncInternal>d__4`1.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at AzureTable.Program.<RetrieveEntity>d__3.MoveNext() in D:Manish PracticeAzureItAzureTableProgram.cs:line 46
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at AzureTable.Program.Main(String args) in D:ManishPracticeAzureItAzureTableProgram.cs:line 21
Inner Exception 1:
MissingMethodException: No parameterless constructor defined for this object.
BlogEntity class :
public class BlogEntity : TableEntity
{
public BlogEntity(int ID, string author, string title, string description)
{
this.UniqueID = ID;
this.Author = author;
this.Title = title;
this.Description = description;
this.PartitionKey = "blog";
this.RowKey = ID.ToString();
}
public int UniqueID { get; set; }
public string Author { get; set; }
public string Title { get; set; }
public string Description { get; set; }
}
c#



add a comment |
Trying to handle Azure storage table operations using .net core. I have successfully added a new storage table and inserted the new row with unique rowKey (I tested the insertion with re-insertion which gave me conflict which means it already has a key). When I am trying to retrieve the same key with rowKey =1 which I have inserted then getting an error.
CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(StorageConnectionString);
//create storage table
CreateTable(cloudStorageAccount).GetAwaiter().GetResult();
InsertEntity(cloudStorageAccount).GetAwaiter().GetResult();
RetrieveEntity(cloudStorageAccount, "blog", "1").GetAwaiter().GetResult();
public static async Task RetrieveEntity(CloudStorageAccount cloudStorageAccount,
string partitionKey, string rowKey)
{
var cloudTableClient = cloudStorageAccount.CreateCloudTableClient();
var cloudTableReference = cloudTableClient.GetTableReference("MyAzureTableStorage");
TableOperation retrieve = TableOperation.Retrieve<BlogEntity>(partitionKey, rowKey);
var result = await cloudTableReference.ExecuteAsync(retrieve);
if(result.Result == null)
{
Console.WriteLine("Not able to find the results");
}
else
{
Console.WriteLine($"Blog found for author: {((BlogEntity)result.Result).Author}");
}
}
Getting an error:
Microsoft.WindowsAzure.Storage.StorageException
HResult=0x80131500
Message=No parameterless constructor defined for this object.
Source=Microsoft.WindowsAzure.Storage
StackTrace:
at Microsoft.WindowsAzure.Storage.Core.Executor.Executor. <ExecuteAsyncInternal>d__4`1.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at AzureTable.Program.<RetrieveEntity>d__3.MoveNext() in D:Manish PracticeAzureItAzureTableProgram.cs:line 46
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at AzureTable.Program.Main(String args) in D:ManishPracticeAzureItAzureTableProgram.cs:line 21
Inner Exception 1:
MissingMethodException: No parameterless constructor defined for this object.
BlogEntity class :
public class BlogEntity : TableEntity
{
public BlogEntity(int ID, string author, string title, string description)
{
this.UniqueID = ID;
this.Author = author;
this.Title = title;
this.Description = description;
this.PartitionKey = "blog";
this.RowKey = ID.ToString();
}
public int UniqueID { get; set; }
public string Author { get; set; }
public string Title { get; set; }
public string Description { get; set; }
}
c#



Trying to handle Azure storage table operations using .net core. I have successfully added a new storage table and inserted the new row with unique rowKey (I tested the insertion with re-insertion which gave me conflict which means it already has a key). When I am trying to retrieve the same key with rowKey =1 which I have inserted then getting an error.
CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(StorageConnectionString);
//create storage table
CreateTable(cloudStorageAccount).GetAwaiter().GetResult();
InsertEntity(cloudStorageAccount).GetAwaiter().GetResult();
RetrieveEntity(cloudStorageAccount, "blog", "1").GetAwaiter().GetResult();
public static async Task RetrieveEntity(CloudStorageAccount cloudStorageAccount,
string partitionKey, string rowKey)
{
var cloudTableClient = cloudStorageAccount.CreateCloudTableClient();
var cloudTableReference = cloudTableClient.GetTableReference("MyAzureTableStorage");
TableOperation retrieve = TableOperation.Retrieve<BlogEntity>(partitionKey, rowKey);
var result = await cloudTableReference.ExecuteAsync(retrieve);
if(result.Result == null)
{
Console.WriteLine("Not able to find the results");
}
else
{
Console.WriteLine($"Blog found for author: {((BlogEntity)result.Result).Author}");
}
}
Getting an error:
Microsoft.WindowsAzure.Storage.StorageException
HResult=0x80131500
Message=No parameterless constructor defined for this object.
Source=Microsoft.WindowsAzure.Storage
StackTrace:
at Microsoft.WindowsAzure.Storage.Core.Executor.Executor. <ExecuteAsyncInternal>d__4`1.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at AzureTable.Program.<RetrieveEntity>d__3.MoveNext() in D:Manish PracticeAzureItAzureTableProgram.cs:line 46
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at AzureTable.Program.Main(String args) in D:ManishPracticeAzureItAzureTableProgram.cs:line 21
Inner Exception 1:
MissingMethodException: No parameterless constructor defined for this object.
BlogEntity class :
public class BlogEntity : TableEntity
{
public BlogEntity(int ID, string author, string title, string description)
{
this.UniqueID = ID;
this.Author = author;
this.Title = title;
this.Description = description;
this.PartitionKey = "blog";
this.RowKey = ID.ToString();
}
public int UniqueID { get; set; }
public string Author { get; set; }
public string Title { get; set; }
public string Description { get; set; }
}
c#



c#



edited Nov 21 '18 at 7:44


Jayendran
3,31331337
3,31331337
asked Nov 21 '18 at 5:26
ironmanironman
12439
12439
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Adding to the BlogEntity
class a parameterless constructor should solve the issue:
public class BlogEntity : TableEntity
{
public BlogEntity() { }
public BlogEntity(int ID, string author, string title, string description)
{
this.UniqueID = ID;
this.Author = author;
this.Title = title;
this.Description = description;
this.PartitionKey = "blog";
this.RowKey = ID.ToString();
}
public int UniqueID { get; set; }
public string Author { get; set; }
public string Title { get; set; }
public string Description { get; set; }
}
Hope it helps!
Why we need an empty constructor. Is it doing serialization? I did not get the reason for an empty constructor.
– ironman
Nov 21 '18 at 14:46
1
Deserialization requires an empty constructor
– Itay Podhajcer
Nov 21 '18 at 15:04
That is what I was doubting but I did not find this anywhere in the documentation.
– ironman
Nov 21 '18 at 18:41
It's probably because it's a general .net serialization requirement.
– Itay Podhajcer
Nov 21 '18 at 18:56
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53405731%2fretrieving-row-from-azure-table-storage%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Adding to the BlogEntity
class a parameterless constructor should solve the issue:
public class BlogEntity : TableEntity
{
public BlogEntity() { }
public BlogEntity(int ID, string author, string title, string description)
{
this.UniqueID = ID;
this.Author = author;
this.Title = title;
this.Description = description;
this.PartitionKey = "blog";
this.RowKey = ID.ToString();
}
public int UniqueID { get; set; }
public string Author { get; set; }
public string Title { get; set; }
public string Description { get; set; }
}
Hope it helps!
Why we need an empty constructor. Is it doing serialization? I did not get the reason for an empty constructor.
– ironman
Nov 21 '18 at 14:46
1
Deserialization requires an empty constructor
– Itay Podhajcer
Nov 21 '18 at 15:04
That is what I was doubting but I did not find this anywhere in the documentation.
– ironman
Nov 21 '18 at 18:41
It's probably because it's a general .net serialization requirement.
– Itay Podhajcer
Nov 21 '18 at 18:56
add a comment |
Adding to the BlogEntity
class a parameterless constructor should solve the issue:
public class BlogEntity : TableEntity
{
public BlogEntity() { }
public BlogEntity(int ID, string author, string title, string description)
{
this.UniqueID = ID;
this.Author = author;
this.Title = title;
this.Description = description;
this.PartitionKey = "blog";
this.RowKey = ID.ToString();
}
public int UniqueID { get; set; }
public string Author { get; set; }
public string Title { get; set; }
public string Description { get; set; }
}
Hope it helps!
Why we need an empty constructor. Is it doing serialization? I did not get the reason for an empty constructor.
– ironman
Nov 21 '18 at 14:46
1
Deserialization requires an empty constructor
– Itay Podhajcer
Nov 21 '18 at 15:04
That is what I was doubting but I did not find this anywhere in the documentation.
– ironman
Nov 21 '18 at 18:41
It's probably because it's a general .net serialization requirement.
– Itay Podhajcer
Nov 21 '18 at 18:56
add a comment |
Adding to the BlogEntity
class a parameterless constructor should solve the issue:
public class BlogEntity : TableEntity
{
public BlogEntity() { }
public BlogEntity(int ID, string author, string title, string description)
{
this.UniqueID = ID;
this.Author = author;
this.Title = title;
this.Description = description;
this.PartitionKey = "blog";
this.RowKey = ID.ToString();
}
public int UniqueID { get; set; }
public string Author { get; set; }
public string Title { get; set; }
public string Description { get; set; }
}
Hope it helps!
Adding to the BlogEntity
class a parameterless constructor should solve the issue:
public class BlogEntity : TableEntity
{
public BlogEntity() { }
public BlogEntity(int ID, string author, string title, string description)
{
this.UniqueID = ID;
this.Author = author;
this.Title = title;
this.Description = description;
this.PartitionKey = "blog";
this.RowKey = ID.ToString();
}
public int UniqueID { get; set; }
public string Author { get; set; }
public string Title { get; set; }
public string Description { get; set; }
}
Hope it helps!
answered Nov 21 '18 at 5:42
Itay PodhajcerItay Podhajcer
1,9891412
1,9891412
Why we need an empty constructor. Is it doing serialization? I did not get the reason for an empty constructor.
– ironman
Nov 21 '18 at 14:46
1
Deserialization requires an empty constructor
– Itay Podhajcer
Nov 21 '18 at 15:04
That is what I was doubting but I did not find this anywhere in the documentation.
– ironman
Nov 21 '18 at 18:41
It's probably because it's a general .net serialization requirement.
– Itay Podhajcer
Nov 21 '18 at 18:56
add a comment |
Why we need an empty constructor. Is it doing serialization? I did not get the reason for an empty constructor.
– ironman
Nov 21 '18 at 14:46
1
Deserialization requires an empty constructor
– Itay Podhajcer
Nov 21 '18 at 15:04
That is what I was doubting but I did not find this anywhere in the documentation.
– ironman
Nov 21 '18 at 18:41
It's probably because it's a general .net serialization requirement.
– Itay Podhajcer
Nov 21 '18 at 18:56
Why we need an empty constructor. Is it doing serialization? I did not get the reason for an empty constructor.
– ironman
Nov 21 '18 at 14:46
Why we need an empty constructor. Is it doing serialization? I did not get the reason for an empty constructor.
– ironman
Nov 21 '18 at 14:46
1
1
Deserialization requires an empty constructor
– Itay Podhajcer
Nov 21 '18 at 15:04
Deserialization requires an empty constructor
– Itay Podhajcer
Nov 21 '18 at 15:04
That is what I was doubting but I did not find this anywhere in the documentation.
– ironman
Nov 21 '18 at 18:41
That is what I was doubting but I did not find this anywhere in the documentation.
– ironman
Nov 21 '18 at 18:41
It's probably because it's a general .net serialization requirement.
– Itay Podhajcer
Nov 21 '18 at 18:56
It's probably because it's a general .net serialization requirement.
– Itay Podhajcer
Nov 21 '18 at 18:56
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53405731%2fretrieving-row-from-azure-table-storage%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown