Azure not saving records
I am not sure what is really going on. I followed the example in this tutorial and the tables were created on Azure....but the data does not seem to save there. It saves locally though. I cannot figure out why the data is not saving on the server.
I have follwed every tutorial to the "T" but I cannot get data to save to Azure.
I am coping in my code for the client below.
public async Task Initialize()
{
if(client?.SyncContext?.IsInitialized ?? false)
{
return;
}
var appUrl = "https://nfwebapp2021.azurewebsites.net";
client = new MobileServiceClient(appUrl);
var fileName = "MyDB.db";
var store = new MobileServiceSQLiteStore(fileName);
store.DefineTable<MyTable>();
await client.SyncContext.InitializeAsync(store);
appSettingsTable = client.GetSyncTable<MyTable>();
}
public async Task SyncMyTable()
{
await Initialize();
try
{
if (Xamarin.Essentials.Connectivity.NetworkAccess != Xamarin.Essentials.NetworkAccess.Internet)
{
return;
}
await client.SyncContext.PushAsync();
await rifleTable.PullAsync("allRifles", rifleTable.CreateQuery().Where(x => x.UserId == App.UserId));
}
catch (Exception ex)
{
App.logger.Error(ex.ToString());
}
}
public async Task<List<MyTable>> GetMyTable()
{
await Initialize();
await SyncMyTable);
var myTable= (await myTable.Where(x => x.UserId == App.UserId).ToListAsync());
return myTable?? new List<MyTable>();
}