Azure database not working after deploying .net core react js project - azure

I am completely noob to Azure. When I try to publish .net core app on Azure. its published and interface is showing, but it seems like database is not working i am unable to submit form data. in console it gives 500 error. here is the link:
Azure site link

There are a few steps that you can follow to solve this.
Check your appsettings.json - Check whether you have put the connection string in your appsettings.json
Validate the connection string - This might be a result of a wrong connection string. You can get the correct connection string from the Azure Database. It's something similar to this (Server=tcp:mssql-care-dev.database.windows.net,1433;Initial Catalog=sqldb-care-dev;Persist Security Info=False;User ID=MsSqlAdmin;Password={your_password};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;)
Replace {your_password} with your actual password. And the SQL server name.
Add a debug point in your application. And then run the local application against the hosted database. This will give you an insight into what's happening.

Related

Connect Kentico through Azure SQL

I've followed this tutorial https://docs.kentico.com/k12sptutorial/mvc-development and successfully run it on localhost, however when I try to publish to Azure app service the connection string doesn't seem to work at all and I've tried all the fixes including changing region of all services to be in one region, whitelist IP addresses.
here is the link of the site:
https://adia.azurewebsites.net
connection string:
Data Source=tcp:adiadb.database.windows.net,1433;Initial Catalog=adia;User Id=sqladmin#adiadb;Password=password
Please advice when went wrong. Thanks.
It looks like the DB is not available to other resources within Azure. You’re able to connect with SQL Management Studio, but not the Web application. When you create the database, there is a checkbox to make it available to other resources within Azure. By default this is disabled. I’m not at my computer just now, but I’ll update this when I am with a screenshot of where to check.

Azure Web App and .NetCore WebAPI - Missing web.config

From what I understand .NetCore no longer uses/needs web.config -- opting instead for appsettings.json.
I have a .NetCore WebAPI that I am trying to host in an Azure WebApp. I've published the API to the WebApp but I keep getting a 500 error. Looking in the Application logs, I can see that the error is:
IIS was not able to access the web.config file for the web site or application.
I'm confused. If .NetCore uses appsettings.json instead of web.config and Azure won't work without web.config, how is one supposed to host a .NetCore app in Azure?
UPDATE
I now realize that this has nothing to do with web.config thanks to #joey-cai pointing me in the right direction.
It appears that Azure did not like my attempt to use Azure Active Directory Authentication in my Connection String. I changed my connection string to simply use SQL Authentication and everything worked. So I guess my question now is, how do I use AAD Authentication for my connection string rather than SQL Authentication.
This SO thread seems to indicate that my connection string was indeed set up correctly for AAD authentication, but I was getting the error:
Keyword not supported: 'authentication'
whenever I used the connection string like so:
Server=tcp:dbname.database.windows.net,1433;Initial Catalog=dbnamesqldb;Persist Security Info=False;User ID={your_username};Password={your_password};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Authentication="Active Directory Password";
Since the question has now changed, I'm going to create a new post with the new question.
does this mean I must have we.config? If so, can it just be an empty file?
When you deploy the .net core project to Azure, you could go to https://xxxxx.scm.azurewebsites.net and click Debug console> CMD > site > wwwroot > web.config. The web.config will be there.
Try to delete the site in azure and recreat the site in azure. Also, try to run the application that you are deploying by running dotnet MyApp.dll and making sure that works. You need more details as to why it’s having an application issue. This might help. Also consider testing using a self contained application. Also try installing the asp.net core extension on the azure app service.
For more details, you could refer to Deploy ASP.NET Core apps to Azure App Service.

Azure SQL Database Error, but works in localhost debug mode

I have a question regarding asp.NET Core and Azure SQL Database
We can successfully connect to Azure SQL DB via the localhost or VS Debug. I used the same Publish connection string to update the appsettings.json "DefaultConnection". We continue to get an error on Azure URL when trying to login or register. It is not able to connect to the same Azure SQL database successfully.
Also, we get the standard error, which is set correctly in the config files.
Error. An error occurred while processing your request. Development Mode Swapping to Development environment will display more detailed information about the error that occurred. Development environment should not be enabled in deployed applications, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the ASPNETCORE_ENVIRONMENT environment variable to Development, and restarting the application.
Not sure what the issue is with Azure connecting to the database...any help appreciated. To recap, it works with the Azure SQL DB from local host, and the DefaultConnection is the same for both versions.
If I recall correctly, the Azure Web Apps do a bit of work under the covers to make it possible to change the connection string from the portal; as a result, it may complicate the process you attempted to use with "publish", as it may not update the key-value pairs that it stores the connection string as. AFAIK, updating/publishing again will update the code, but not the existing values that are in the key-value store.
This is detailed here: how connection strings work in Azure Web Apps

Connecting to Azure DB from Cloud Service utilizing Entity Framework

I am trying to connect to an Azure SQL Server database from an Azure Cloud Services project through entity framework, but am getting an error of "The underlying provider failed on Open."
I repeated the same process of adding entity framework which I took to create my cloud service on a console based application and the console application was able to successfully connect to the Azure database. For some reason this is not the case with my Cloud Services project. After a few hours of trouble shooting, I think that the problem could lie with my connection string. Can somebody with experience on these technologies please help out? I would really appreciate it. I am new to Azure and so far I think it's great but this is my obstacle right now.
<add name="myProjectDBEntities" connectionString="metadata=res://*/myProject1myProjectModel.csdl|res://*/myProject1myProjectModel.ssdl|res://*/myProject1myProjectModel.msl;provider=System.Data.SqlClient;provider connection string="data source=f55bjjg4wt.database.windows.net;initial catalog=myProjectDB;user id={loginID};password={password};MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient"/>
You can set your connectionstring in Azure Cloud Service, and it will work.
Same as this in cloud service:
https://docs.google.com/file/d/0B8TtY9U9VCvqeXRMbkFWM000ZnM/edit
Also, you can find "show connectionstring" on your Azure SQL Server database Dashboard.
Copy and paste to your connectionString part. And remember to set your password.
Hope it will help you.

Azure - Changed admin password for DB and now can't access database

I have a Azure account and have deployed an MVC app.
I changed the admin password for the db and updated my web.config accordingly and after I've published the app, the app can't access the db. I get the following error:
Login failed for user 'xxx'.
This session has been assigned a tracing ID of '11a7a162-ff21-42f0-a8ea-8e5ce25b8ab6'.
Provide this tracing ID to customer support when you need assistance.
Any help appreciated. I've been over everything with a fine toothcomb and I can login to the db using SQL Management studio using the new credentials. The DB is dead however.
The only other thing I did was change the size of the DB from 1GB to 5GB.
I managed to fix this and for anyone out there, here's the gotcha. Even when I changed the connection strings in the publish profile, they were ignored. I had to go to the Azure portal and change the connection string settings against the deployed web app directly.
I wonder whether this is a bug with Azure. I would have expected my publish profile settings to change the connection strings on the deployed application.

Resources