I am trying to save a single variable "userinput" into my Azure table storage, the variable populates with the first message the user send to the chat bot, when the user sends "no" to the bot.
This is my current code for uploading the variable "userinput" into my table storage:
private void storeuserinput(Activity activity)
{
var uid = activity.From.Id;
var uname = activity.From.Name;
if (activity.Text?.ToLower().ToString() == "no" || activity.Text?.ToLower().ToString() == "NO" || activity.Text?.ToLower().ToString() == "No" || activity.Text?.ToLower().ToString() == "Nope" || activity.Text?.ToLower().ToString() == "nope")
{
var userinput = firstmessage;
// Parse the connection string and return a reference to the storage account.
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
// Create the table client.
CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
// Retrieve a reference to the table.
CloudTable table = tableClient.GetTableReference("NoSolutionFound");
// Create a new customer entity.
unansweredQuestion input = new unansweredQuestion();
input.Query = userinput;
// Create the TableOperation object that inserts the customer entity.
TableOperation insertOperation = TableOperation.Insert(input);
// Execute the insert operation.
table.Execute(insertOperation);
}
//extract other data from "activity" object
//your code logic here
//store data in your table storage
//Note: specifcial scenario of user send attachment
}
public class unansweredQuestion : TableEntity
{
public unansweredQuestion() { } // the parameter-less constructor must be provided
public string Query { get; set; }
}
My storage table remains empty when my code is run and two errors appear inthe output box:
Microsoft.WindowsAzure.ServiceRuntime Error: 102 : Role environment . FAILED TO INITIALIZE. hr: -2147024894
Getting "StorageConnectionString" from ServiceRuntime: FAIL.
Exception thrown: 'Microsoft.WindowsAzure.Storage.StorageException' in Microsoft.WindowsAzure.Storage.dll