0

Facing a very strange issue.

Following this guide https://azure.microsoft.com/en-in/documentation/articles/app-service-mobile-xamarin-forms-blob-storage/ to implement File Sync in Xamarin Forms app.

The Get method in my service (GetUser, default get method in App service controller) is being called thrice & on the 3rd iteration it gives me a 404 resource not found error. First 2 iterations work fine. This is the client call

await userTable.PullAsync(
                        null,
                        userTable.Where(x => x.Email == userEmail), false, new System.Threading.CancellationToken(), null);

If I remove the following line,

// Initialize file sync
this.client.InitializeFileSyncContext(new TodoItemFileSyncHandler(this), store);

then the code works just fine, without any errors. I will need some time doing a sample project, meanwhile if anyone can shed some light, it will be of help.

Thanks

Supreet
  • 831
  • 1
  • 9
  • 30

2 Answers2

0

This won't be an answer, because there isn't enough information to go on. When you get a 404, it's because the backend returned a 404. The ideal situation is:

  • Turn on Diagnostic Logging in the Azure Portal for your backend
  • Use Fiddler to monitor the requests
  • When the request causes a 404, look at what is actually happening

If you are using an ASP.NET backend (and I'm assuming you are because all the File tutorials use ASP.NET), then you can set a breakpoint on the appropriate method in the backend and follow it through. You will need to deploy a debug version of your code.

Adrian Hall
  • 7,990
  • 1
  • 18
  • 26
  • Thanks for the comments @Adrian. I am indeed using Asp.Net backend. My question is as soon as I comment the code that initializes file sync, everything works as normal. This app has been working for past 6 months just the same. to summarize switch on the code for FileSync & I get 404, comment it out & all is good again. This gives me a suspicion that it is the File Sync that is playing with something here, – Supreet Sep 20 '16 at 04:50
  • Microsoft.WindowsAzure.MobileServices.MobileServiceInvalidOperationException: The resource you are looking for has been removed, had its name changed, or is temporarily unavailable. That's the exact error I get. I have now tried updating all nuget packages, consolidating them all to same version. As I said earlier though, as soon as I comment the line that initializes the File Sync, everything works as expected. – Supreet Sep 20 '16 at 13:13
  • Which specific endpoint is giving you the 404? That's what you are looking for. – Adrian Hall Sep 21 '16 at 21:00
  • https://drive.google.com/open?id=0BzYXG8uD6JT3ai1SN3lfRE5oNWs I ave re created the issue I am facing in this sample. This does not give me a 404 error but a 500, symptoms are same though. If you comment the file sync related code in AzureHelper.cs at line numbers 44, 46 & 74 and uncomment the data sync call at Line number 41 it works as expected. Comment the code for LN 41 & uncomment for File Sync at 44, 46, 74 & run the code, you get a 500 error. This is what led me to believe that the error is somewhere in File Sync changes, just can't figure out what block? – Supreet Sep 22 '16 at 11:25
  • Supreet - you have not answered the question originally posed - what endpoint is causing the error? Until we know that, we can't help you. – Adrian Hall Sep 23 '16 at 22:00
  • Hi Adrian, I don't know which end point causes the issue. As soon as File Sync code is used, I click on sync to call the sync async method (following this tutorial https://azure.microsoft.com/en-in/documentation/articles/app-service-mobile-xamarin-forms-blob-storage/) it called Get method for todo Items which is successfully executed & when I am back on client I get this error in a Error Box. The error is never caught on any of the catch blocks, so I can't be sure whice end point causes it. If you run the sample app you will see what I mean. Thanks – Supreet Sep 24 '16 at 12:49
  • Then, as suggested in the answer I gave, you need to install Fiddler and determine it through observation. I suspect you have not written the appropriate controller for getting the SAS token for the file sync. The fiddler trace will provide that. – Adrian Hall Sep 24 '16 at 20:08
  • Thanks Adrian, I'll try fiddler today. But if you see the sample code, I definitely have the controller to generate the SAS tokens. If you could just give a try to the attached solution, you will notice that I've taken care of all common pitfalls that I could think of. I'll try fiddler today & will update here if I find something new. – Supreet Sep 26 '16 at 01:44
  • Hi Adrian, using fiddler I figured out it's trying to find files for my User object too GET /tables/User/0d8e214a-ba22-447a-9eb5-4afb36f4c5b4/MobileServiceFiles HTTP/1.1 which it don't understand why? I have several entities in my app & I intend to use files for only a few of them. User entity is not one of them. So 2 questions here: 1. Will it try & find a file for each DTO I have in my app? 2. If so, how do I restrict it to only a few selected ones? Looking forward for your response. Thanks – Supreet Sep 26 '16 at 09:58
  • Here is my reportStorageController code https://gist.github.com/supreettare/62250b07d35e0aef9c553691553f188f you can see it clearly is based on Report class, I don't see why the method is also getting called for User class as detailed in the comment above. Any help in correct direction is really appreciated. P.S. this does not happen in a sample project – Supreet Sep 26 '16 at 13:22
0

this is sorted now, eventually I had to give it what it was asking for. I had to create a storage controller for User too, although I don't need one as I don't need to save any files in storage against the users.

I am testing the app further now to see if this sorts my problem completely or I need a storage controller for every entity I use in my app.

In which case it will be really odd as I don't intend to use the storage for all my entities.

Supreet
  • 831
  • 1
  • 9
  • 30
  • This issue is logged in github & there is a workaround https://github.com/azure-appservice-samples/ContosoMoments/blob/master/src/Mobile/ContosoMoments/Helpers/FileSyncTriggerFactory.cs https://github.com/Azure/azure-mobile-apps-net-files-client/issues/34 – Supreet Sep 28 '16 at 09:53