Share via

Using sql server defined in web api in azure

Mustafa Erdağlı 0 Reputation points
2023-04-10T15:12:17.3966667+00:00

Hello. I use the sql server that I use in local, and I also use the web api. I don't get runtime errors. but when publishing the web api. I can't access my data in sql server. Do I have to define sql server in Azure? I want to use sql server on my own computer. sql server i am using mssql server 2018 the version i am using is aspnet core 6 web api

Developer technologies | ASP.NET Core | Other
0 comments No comments

1 answer

Sort by: Most helpful
  1. Anonymous
    2023-04-11T06:46:32.9066667+00:00

    Hi @Mustafa Erdağlı, According to your description, the cause of the problem is that there is no database to use.

    Question: Do I have to define sql server in Azure?

    Answer : If you have a physical server locally and have a public IP address, or an intranet penetration tool (like Ngrok) that enables remote access to the 1433 database port, then you do not need to create a SQL Database on Azure(Or other cloud database service).

    You also mentioned this I want to use sql server on my own computer. My suggestion is that if you're just using it for individual developers or test environments, i.e. not very concerned about data security, then we can use ngrok and access the local database. For more specific steps, please refer to this link.

    Tips

    1. Please ensure you have allowed Remote Access to the Database
    2. After you configured your sql server, you can test the connection info generated by ngrok in SSMS.
    3. After confirming the connection string is valid, you need to replace the previous one in appsettings.json file

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,

    Jason Pan

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.