0

So, I have an app that I want to deploy in azure. I was successfully able to deploy app to my azure url that I created. The Html page loads correctly, the JavaScript is working as expected. However, my data is not loading at all. When I looked in the debugger it was giving me a 500 error. I am not sure where I am going wrong. I do have my connection string in my web.config. My database is located on another server. I am not sure how to give azure access to it and then connect it to my help. Please let me know if you need more help.

   [The first one is the console error][1]
   [The second one is what my app looks like][2]
  [My updated config][3]

  [1]: https://i.stack.imgur.com/4gYhY.png
  [2]: https://i.stack.imgur.com/gLtvz.png
  [3]: https://i.stack.imgur.com/N5gzS.png
  [error][1]


  [1]: https://i.stack.imgur.com/kX4Jp.png
rabyusbeef
  • 11
  • 1
  • 1
  • 6
  • My app works perfectly in my local environment – rabyusbeef Apr 02 '18 at 13:34
  • I am also using entity framework – rabyusbeef Apr 02 '18 at 13:35
  • you can edit the question, add your comments there. Where is your database hosted? – Hussein Salman Apr 02 '18 at 13:38
  • You could refer to my this [article](https://stackoverflow.com/questions/49184932/azure-error-connection-string-difficulties/49185929#49185929) to check. – Janley Zhang Apr 02 '18 at 13:42
  • I have a servor on which it is hosted. – rabyusbeef Apr 02 '18 at 13:51
  • @JanleyZhang I was able to access the server in my visualstudio through the method that you mentioned. Do I add the same in my web.config? – rabyusbeef Apr 02 '18 at 14:04
  • You could click Test Connection button to test whether you could connect your database successfully. Then you could use connection string in web.config file to test whether you could use database in your project locally. Finally, you could test whether you could use database after you published your project to Azure. – Janley Zhang Apr 02 '18 at 14:06
  • @JanleyZhang So, I loaded all my dbs in my server explorer and it worked, it also works locally but not when I publish it. When I publish it, it gives me a 500 error. Do you think you can walk me through ? – rabyusbeef Apr 02 '18 at 14:28
  • So your issue is related with Azure portal. I guess the Azure can not recognize your personal server. It thinks your database server url is unsafe. I suggest you could use Azure sql directly. – Janley Zhang Apr 02 '18 at 14:33
  • You mean move my database to azure? @Janley Zhang – rabyusbeef Apr 02 '18 at 14:36
  • There are few other apps that are using the same connection strings and are working when published through azure. However, the app service, app registrations are different for those apps but hey are all pulling from the same db. – rabyusbeef Apr 02 '18 at 14:39
  • Also, there is an azure gateway app that runs on the server in which the db is located that allows Azure to connect to the database. – rabyusbeef Apr 02 '18 at 14:43
  • @Or you could try to delete your exist project to republish again. Maybe there is some error in your exisit project. Just choose the remove additional files at destination check box in Publish. You could refer to this [article](https://msdn.microsoft.com/en-us/library/dd465337(v=vs.110).aspx). – Janley Zhang Apr 02 '18 at 14:57
  • @JanleyZhang I just added pticures – rabyusbeef Apr 02 '18 at 15:04
  • There are many connection strings. It's a little difficult to troubleshoot. For EF,you could check it from this [article](https://stackoverflow.com/questions/36559467/sql-azure-ef-database-first-connection-string-in-azure-management-portal). – Janley Zhang Apr 02 '18 at 15:10
  • @JanleyZhang Just updated the config – rabyusbeef Apr 02 '18 at 16:18
  • Actually, I want to know what connnection string you really want to use in your project. Or all connection strings. If all, did you ensure each one could connect successfully? – Janley Zhang Apr 02 '18 at 16:34
  • @JanleyZhang yes I want to use all and yes all of them connect individually – rabyusbeef Apr 02 '18 at 18:32
  • In my opinion, you could check the related connection string one by one. Ignore the other connection string( comment out your code). Just use the related connection string to get data from database after you published project in Azure. Then you could test which one is the issue connection string. – Janley Zhang Apr 03 '18 at 00:54
  • @JanleyZhang- I tried commenting out the connection strings one by one and published them but it still gives me the 500 error. – rabyusbeef Apr 03 '18 at 20:47
  • What about try to select the Remove addtional files at destination check box in [publish settings](https://stackoverflow.com/questions/17476525/clean-windows-azure-website). Maybe the error is your old file in project. You could remove old project and republish again. And in your error screenshot, it shows an error source from 'api/Assignments' rest api. I think the error is from your internal code. – Janley Zhang Apr 04 '18 at 02:24
  • ok, I will try that. I don't think its an error from the internal code because it works perfectly on my local environment. – rabyusbeef Apr 04 '18 at 13:06

1 Answers1

0

So, I figure out the problem. I am using a feature called Azure app service hybrid connection. In this setting I set how it should access the server on which my database is located at. Once these settings were made, I just published my app as usual and it worked and loads the data from the database. These links helped me: https://learn.microsoft.com/en-us/azure/app-service/app-service-hybrid-connections https://learn.microsoft.com/en-us/azure/biztalk-services/integration-hybrid-connection-overview

rabyusbeef
  • 11
  • 1
  • 1
  • 6