question

CrystalYU-8798 avatar image
0 Votes"
CrystalYU-8798 asked Karthik-4764 published

SQL Server: RequestError: Invalid object name 'Table Name'.

I create an database in the azure. And try to access the table in app service. When I start the app service in local machine, and it works fine. but When I deploy the app service in azure, the app service will fail to access the table, the error is 'RequestError: Invalid object name '[table Name]'.'

What's the problem and how can I fix the issue?

Thanks,

azure-sql-database
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

OuryBa-MSFT avatar image
0 Votes"
OuryBa-MSFT answered Karthik-4764 published

Hello @CrystalYU-8798 In addition to what Morillo mentioned above on the root cause of the issue.
1. Are you getting this error on only one table or for all tables , if you are seeing this on only one table then you simply made a mistake in naming when creating the table.
2. If it is for all tables , then you may need to verify if schema name is the same on Azure
3. List item

Please let us know

Regards,
Oury




· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

The issue is resolved. Thanks

1 Vote 1 ·

@CrystalYU-8798 can you tell us how was this resolved ? Did you do anything other. than the things that are suggested in the thread.
We havee all these things and its still not working for us.

0 Votes 0 ·
CrystalYU-8798 avatar image
0 Votes"
CrystalYU-8798 answered CrystalYU-8798 commented

I specified the database name in the connection config(see following) when I try to connect it. And the app service deployed in Azure is the same code with the one deployed local.
var config = {
user: user,
password: password,
server: server,
database: database,
};

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Did you created the login in the master database and then created the user associated to that login on the user database? Or that user is a contained database user? Did you provided permissions to that user over that table?

1 Vote 1 ·

I created the database in portal, in the wizard, it asked me to create a sql server, in the pop-up sql-server-creation page, I set the user/password.

So do you mean that the user/password only have permission to access the master database? Then where can I grant the access permission to the user for my database?

Another strange thing is that the app service deployed in local machine can access my database, but if I deployed the same service (the same code) into Azure app service, it cannot access the database.

0 Votes 0 ·
AlbertoMorillo avatar image
0 Votes"
AlbertoMorillo answered CrystalYU-8798 commented

In your code, you may be connecting directly to the master database. Do not forget to specify the database name you are connecting once you get connected to the logical SQL Azure server (server1.database.windows.net). Make sure the database name on Azure match the database name you use on your local SQL instance.

Update your app service with the correct database name, table name, and logical Azure SQL server name, as they may not be the same as your local environment.

Make sure the table exist on the same schema.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I specified the database name in the connection config(see following) when I try to connect it. And the app service deployed in Azure is the same code with the one deployed local.
var config = {
user: user,
password: password,
server: server,
database: database,
};

1 Vote 1 ·