Sam
Sam

Reputation: 1

403 Authentication Error when access Windows Azure Storage Table In Xamarin

SAS Token Error IN Xamarin Studio IMAGE

I have been trying to use xamarin studio in VS2k15 for android app development.the database i use is azure storage table.

so in order to use azure storage table in xamarin you need a SAS( shared access signature) instead of Access key.

I generated the SAS token for the table storage yet this exception(as shown in image)is thrown instead of inserting the data.

enter image description here

HTTP 403 means the connection is working and accepting request but it is failing in doing the work.

So please help me out. P.S the sas token is correctly generated ( cannot be shared for security reasons).

my main activity .cs

using Microsoft.WindowsAzure.Storage;

using Microsoft.WindowsAzure.Storage.Table;

namespace App6 { [Activity(Label = "Docapp", MainLauncher = true, Icon = "@drawable/icon")] public class MainActivity : Activity {

    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);

        // Set our view from the "main" layout resource
        SetContentView(Resource.Layout.Main);

        // Get our button from the layout resource,
        // and attach an event to it
        Button button = FindViewById<Button>(Resource.Id.MyButton);

        button.Click += async delegate
        {
            appfix temp = new appfix("public", "1001", "2123212", "djnsjd", DateTime.Today, DateTime.UtcNow, "snjdn", 1233, "JDdjvn", "dsjd", 1212, 0);
            string d = await insert(temp);
            TextView tv = FindViewById<TextView>(Resource.Id.textView1);
            tv.Text = d;
        };


    }




    private async Task<string> insert(appfix temp)
    {
        string sas = "https://supapp.table.core.windows.net/request?sv=2015-04-05&tn=request&sig=FlXvYraZKJIz6YQaRpzVBPORPLsyRKMZHQiAVBPkYP0%3D&spr=http%2Chttp&se=2016-04-01T15%3A44%3A49Z&sp=raud";

        string dec;
        try
        {
            // CloudStorageAccount storageAccount = CloudStorageAccount.Parse(key);

            // CloudTableClient tableClient = storageAccount.CreateCloudTableClient();


            CloudTable table = new CloudTable(new Uri(sas));
                //tableClient.GetTableReference(tableName);

            TableOperation insertEntity = TableOperation.InsertOrReplace(temp);

            await table.ExecuteAsync(insertEntity);

            dec = "DONE";
        }

        catch(Exception e)
        {
            dec = e.ToString();
        }

        return dec;
    }

my appfix class

using Microsoft.WindowsAzure.Storage;

using System.Threading.Tasks;

namespace App6 { public class appfix : TableEntity { public string app_no { get; set; } public string app_with { get; set; } public DateTime app_date { get; set; } public DateTime app_time { get; set; } public string patient_name { get; set; } public int ser_no { get; set; } public string patient_rank { get; set; } public string patient_aliment { get; set; } public int room_no { get; set; } public int app_status { get; set; }

    public appfix()
    {

    }
    public appfix(string partionkey,string rowkey,string App_no, string App_with, DateTime App_date, DateTime App_time, string Patient_name, int Ser_no, string Patient_rank, string Patient_aliment, int Room_no, int App_status)
    {
        this.PartitionKey = partionkey;
        this.RowKey = rowkey;
        this.app_no = App_no;
        this.app_with = App_with;
        this.app_date = App_date;
        this.app_time = App_time;
        this.patient_name = Patient_name;
        this.ser_no = Ser_no;
        this.patient_rank = Patient_rank;
        this.patient_aliment = Patient_aliment;
        this.room_no = Room_no;
        this.app_status = App_status;
    }


}

}

my SAS Token

https://supapp.table.core.windows.net/request?sv=2015-04-05&tn=request&sig=FlXvYraZKJIz6YQaRpzVBPORPLsyRKMZHQiAVBPkYP0%3D&spr=http%2Chttp&se=2016-04-01T15%3A44%3A49Z&sp=raud

Upvotes: 0

Views: 597

Answers (1)

Sam
Sam

Reputation: 1

Solved Issue IMG

The Issue was solved , Thanks to Gaurav Mantri.

First I updated my Azure Power shell from 1.2.3 to 1.3.0 and updated the WindowsAzure Storage from 4.4.1 to 5.0.3 preview.

why i used 5.0.3 because Monoandroid 6.0 supports 5.0.3.

The SAS Token had SPR parameter from 1.2.3 windows azure power shell, but in 1.3.0 the spr parameter is not added.

Hence the error was solved.

Upvotes: 0

Related Questions