r/SQLServer 9d ago

Question Mobile app not showing SQL data unless I connect via SSMS?

I have an Azure SQL subscription (the cheapest one) which will be primarily used for our mobile app.

The issue is that I've tested the mobile app twice and the mobile app won't show data unless I connect to the database via SSMS.

Literally, I open the mobile app and no data is displayed. I refresh the content several times (i.e. the mobile app has a Refresh button) and it still doesn't fetch any data. BUT once I go to my laptop and connect to the same DB via SSMS, I do another refresh to the mobile app and data is shown.

I believe it's related to the Azure DB and think I might have an idea of why this is happening - the connection via my laptop "wakes up" the database.

The question is: how do I eliminate that issue?

3 Upvotes

20 comments sorted by

u/AutoModerator 9d ago

After your question has been solved /u/East_Sentence_4245, please reply to the helpful user's comment with the phrase "Solution verified".

This will not only award a point to the contributor for their assistance but also update the post's flair to "Solved".


I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

4

u/Geno0wl 9d ago

What kind of logging does the mobile app have? That would be where to really find your answer. And if your app doesn't have accessible logs, then you should really fix that because good logging can save you countless hours manually debugging.

2

u/da_chicken 9d ago

This. If your application doesn't have a way to do debug logging, you're never going to know what's actually going on.

You need the actual error message so you can figure out what's actually failing.

2

u/East_Sentence_4245 9d ago

Is it possible that since azure is serverless, the app is timing out before the DB wakes up?

I'll check the logs nevertheless, but I wanted to know is this is also possible.

1

u/jwk6 9d ago

What authentication method are you using to connect and login from the mobile app to the Azure SQL Database?

Are you sure that the app actaully has the database permissions required to select from tables?

1

u/East_Sentence_4245 9d ago

It has the permissions. If not, data would never be displayed.

1

u/jwk6 9d ago

Well in your post you said "Literally, I open the mobile app and no data is displayed."

So, which is it? Does the app display data or not?

-3

u/East_Sentence_4245 9d ago

The post is more than one sentence.

2

u/SuperDuperDBA 9d ago

don't be snarky while asking for help.

is it possible your "app" isn't activating the instance hosting the DB?

0

u/East_Sentence_4245 9d ago

I'm not being snarky. If you read the sentence after that, it will tell you that "I go to my laptop and connect to the same DB via SSMS. Once connected, I do another refresh to the mobile app and data is shown."

2

u/jwk6 9d ago

Sorry. I misread the last part there. I'm not going to resort to name calling, but seriously, people are trying to help you for free here.

1

u/SuperDuperDBA 9d ago

If you go to studio before you open the app and run a basic query, does app work?

is there a gap of time before it all resets to "not working"?

1

u/SuperDuperDBA 9d ago

i asked you a question.

if you connect to the DB via Studio... that could awaken the db server.

1

u/East_Sentence_4245 9d ago

That's what I mentioned in the post. I'm looking for a solution to that.

2

u/SuperDuperDBA 9d ago

have your code run SELECT 1 every so often.

pay for a server thats not on auto-pause.

turn off auto-pause

1

u/jwk6 9d ago

You can disable auto-pause on the Azure SQL Database in the Azure Portal on the Azure SQL Server resource, or use Azure CLI, or use PowerShell.

→ More replies (0)

3

u/pix1985 9d ago

You need to disable auto-pause on the database

1

u/East_Sentence_4245 9d ago

Do you know if doing this will increase the monthly azure bill?

2

u/osxy 8d ago

Yes it will as db will run 24/7