Where to use SAS Token in Xamarin.Android -
i'm making android app connect azure storage account save information in table. when run app in simulator, , press button opens page connects database exception stating "shared key not supported using pcl. please use sas token."
so followed steps generate sas token i'm not sure string. can suggest should place string?
namespace undergroundsports { [activity] public class austinbowlingsignuppage : activity { protected override async void oncreate (bundle savedinstancestate) { base.oncreate (savedinstancestate); setcontentview (resource.layout.austinbowlingsignuppage); edittext austinbowlingfullnameentry = findviewbyid<edittext> (resource.id.austinbowlingfullnameentry); edittext austinbowlingemailentry = findviewbyid<edittext> (resource.id.austinbowlingemailentry); button austinbowlingsubmitbutton = findviewbyid<button> (resource.id.austinbowlingsignupbutton); string sas = "https://undergroundathletes.blob.core.windows.net/underground-container?sv=2015-04-05&sr=c&sig=gcgc28k%2b\nc6uqk9pkhraotshr7zeu%3d&se=2016-04-20t18%3a13%3a31z&sp=rwdl"; string connectionstring = "defaultendpointsprotocol=http;" + "accountname=my_account_name;" + "accountkey=my_account_key"; cloudstorageaccount storageaccount = cloudstorageaccount.parse (connectionstring); cloudtableclient tableclient = storageaccount.createcloudtableclient (); cloudtable austinbowlingathletes = tableclient.gettablereference ("austinbowlingathletestable"); await austinbowlingathletes.createifnotexistsasync(); austinbowlingsubmitbutton.click += async (sender, e) => { austinbowlingathlete austinbowlingathlete1 = new austinbowlingathlete(); austinbowlingathlete1.fullname = austinbowlingfullnameentry.tostring(); austinbowlingathlete1.email = austinbowlingemailentry.tostring(); tableoperation insertoperation = tableoperation.insert(austinbowlingathlete1); await austinbowlingathletes.executeasync(insertoperation); }; } } }
you need create storagecredentials
based on sas token, use credentials create cloudstorageaccount
, call createcloudtableclient
on storage account cloudtableclient
:
storagecredentials creds = new storagecredentials(sas); cloudstorageaccount storageaccount = new cloudstorageaccount(creds, null, null, tablestorageuri, null); cloudtableclient tableclient = storageaccount.createcloudtableclient(); cloudtable austinbowlingathletes = tableclient.gettablereference("austinbowlingathletestable");
everything else stays same.
check example: teal (azure storage sample xamarin)
Comments
Post a Comment