Azure Cloud webapp&Database setup issue

69 views Asked by At

I am new at this, and for a class for college I need to setup a cloud web app with azure. Needless to say, I have no idea what I am doing, and and only following the instructions shown at this guide from https://learn.microsoft.com/en-us/azure/app-service/tutorial-dotnetcore-sqldb-app.

I have followed all the steps perfectly (I think), but have hit an issue with step 4 of generating a database schema. its telling me to run ./migrate through ssh, which I did, and it only gives me a bunch of text that I definitely don't understand, and then at the end it says in red: "LocalDB is not supported on this platform."

I found a post on github saying that LocalDB is not supported on Linux, which is the OS i'm using. I also found another saying that you cant really change the OS. Is there a way to get this working? I found a few things in other posts mentioning other options, like this one: How to connect a localdb from Visual Studio to the published Azure web app?.

I dont really know what to do from here and could use some help.

1

There are 1 answers

0
Aslesha Kantamsetti On

I cloned code from the document which was provided by you.

While creating a web app + database, I chose SQLAzure as the engine and selected "No" for adding Azure Cache for Redis, as shown below.

enter image description here

After clicking the "Review + Create" button, I was prompted to the screen below, where I copied the username and password.

enter image description here

After successfully creating a web app in Azure, I opened the cloned project on my local machine and changed the connection string in appsettings.json.

   "ConnectionStrings": {
    "MyDbConnection": "Server=tcp:<YourServerName>.database.windows.net,1433;Initial Catalog=<yourDataBaseName>-database;Persist Security Info=False;User ID=<UserID>;Password=<Password>;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;;Connection Timeout=30;Authentication="
  }

appsettings.json:

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "AllowedHosts": "*",
  "ConnectionStrings": {
    "MyDbConnection": "Server=tcp:<YourServerName>.database.windows.net,1433;Initial Catalog=kasampledbapp-database;Persist Security Info=False;User ID=<UserID>;Password=<Password>;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;;Connection Timeout=30;Authentication="
  }
}

For migration purposes, I deleted the old migration file and ran the following command in the Package Manager Console.

enable-migrations

add-migration InitialCreate

update-database

After that, go to your Database server in the Azure portal and add your client address as shown below.

enter image description here

Local Output:

enter image description here

To publish, right-click on the project name and select the "Publish" option, as shown below.

enter image description here

enter image description here

enter image description here

In the image below, I selected my web app in Azure.

enter image description here

I successfully published my web app to Azure, as shown below.

enter image description here

Azure App Service Output:

enter image description here