I'm just getting started using Azure Storage. I've been following this nifty tutorial using Xamarin.Android. Here's what I'm trying to do...
I want to create a mobile app that will take users' names and email addresses using EditText fields and save them in a table in an Azure Storage Account. Here's the code I wrote:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Table;
using Android.Preferences;
namespace UndergroundSports
{
[Activity]
public class austinBowlingAthletesList : Activity
{
protected override void OnCreate (Bundle savedInstanceState)
{
base.OnCreate (savedInstanceState);
SetContentView (Resource.Layout.austinBowlingAthletesList);
EditText austinBowlingFullNameEntry = FindViewById<EditText> (Resource.Id.austinBowlingFullNameEntry);
EditText austinBowlingEmailEntry = FindViewById<EditText> (Resource.Id.austinBowlingEmailEntry);
Button austinBowlingSubmitButton = FindViewById<Button> (Resource.Id.austinBowlingSignUpButton);
CloudStorageAccount storageaccount = CloudStorageAccount.Parse ("StorageConnectionString");
CloudTableClient tableClient = storageaccount.CreateCloudTableClient ();
CloudTable austinBowlingAthletes = tableClient.GetTableReference ("austinBowlingAthletesTable");
austinBowlingAthletes.CreateIfNotExistsAsync ();
austinBowlingSubmitButton.Click += (sender, e) => {
austinBowlingAthlete austinBowlingAthlete1 = new austinBowlingAthlete();
austinBowlingAthlete1.fullname = austinBowlingFullNameEntry.ToString();
austinBowlingAthlete1.email = austinBowlingEmailEntry.ToString();
TableOperation insertOperation = TableOperation.Insert(austinBowlingAthlete1);
austinBowlingAthletes.ExecuteAsync(insertOperation);
};
}
}
}
Will this do what I want? It compiled error-free. However, I was expecting to see a table in the Table service section in my Storage Account in the Azure Portal after pressing the submit button. Instead, it says that I don't have any tables yet.
My first thought was that it's not really creating a table because it's only running in the emulator. Am I onto something? Or did I make a mistake somewhere along the line?
Let me know if you want me to give some more details or link any other parts of the solution. I really appreciate the help!