DEV Community

Supraja Tangella
Supraja Tangella

Posted on

๐— ๐—ผ๐˜ƒ๐—ฒ ๐—Ÿ๐—ผ๐—ฐ๐—ฎ๐—น ๐—ฆ๐—ค๐—Ÿ ๐——๐—ฎ๐˜๐—ฎ๐—ฏ๐—ฎ๐˜€๐—ฒ ๐˜๐—ผ ๐—”๐˜‡๐˜‚๐—ฟ๐—ฒ ๐—ฆ๐—ค๐—Ÿ ๐˜„๐—ถ๐˜๐—ต ๐—”๐—ฆ๐—ฃ.๐—ก๐—˜๐—ง ๐—–๐—ผ๐—ฟ๐—ฒ ๐—”๐—ฝ๐—ฝ โ€“ ๐—™๐˜‚๐—น๐—น ๐——๐—ฒ๐—ฝ๐—น๐—ผ๐˜†๐—บ๐—ฒ๐—ป๐˜ ๐—š๐˜‚๐—ถ๐—ฑ๐—ฒ

When deploying an ASP.NET Core app to Azure, you may also need to move your ๐—น๐—ผ๐—ฐ๐—ฎ๐—น ๐—ฆ๐—ค๐—Ÿ ๐—ฆ๐—ฒ๐—ฟ๐˜ƒ๐—ฒ๐—ฟ ๐—ฑ๐—ฎ๐˜๐—ฎ๐—ฏ๐—ฎ๐˜€๐—ฒ to ๐—”๐˜‡๐˜‚๐—ฟ๐—ฒ ๐—ฆ๐—ค๐—Ÿ ๐——๐—ฎ๐˜๐—ฎ๐—ฏ๐—ฎ๐˜€๐—ฒ so your application can access it online. Here's how to do both using ๐—ฉ๐—ถ๐˜€๐˜‚๐—ฎ๐—น ๐—ฆ๐˜๐˜‚๐—ฑ๐—ถ๐—ผ**.

๐—ฆ๐˜๐—ฒ๐—ฝ-๐—ฏ๐˜†-๐—ฆ๐˜๐—ฒ๐—ฝ ๐—š๐˜‚๐—ถ๐—ฑ๐—ฒ

๐—ฆ๐˜๐—ฒ๐—ฝ ๐Ÿญ: ๐—ฃ๐—ฟ๐—ฒ๐—ฝ๐—ฎ๐—ฟ๐—ฒ ๐—ฌ๐—ผ๐˜‚๐—ฟ ๐—”๐—ฆ๐—ฃ.๐—ก๐—˜๐—ง ๐—–๐—ผ๐—ฟ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ท๐—ฒ๐—ฐ๐˜

  • Ensure your project is running locally with the SQL Server database (typically via appsettings.json connection string).

๐—ฆ๐˜๐—ฒ๐—ฝ ๐Ÿฎ: ๐—–๐—ฟ๐—ฒ๐—ฎ๐˜๐—ฒ ๐—”๐˜‡๐˜‚๐—ฟ๐—ฒ ๐—ฆ๐—ค๐—Ÿ ๐——๐—ฎ๐˜๐—ฎ๐—ฏ๐—ฎ๐˜€๐—ฒ

  1. In ๐—ฉ๐—ถ๐˜€๐˜‚๐—ฎ๐—น ๐—ฆ๐˜๐˜‚๐—ฑ๐—ถ๐—ผ > ๐—ฉ๐—ถ๐—ฒ๐˜„ > ๐—ฆ๐—ค๐—Ÿ ๐—ฆ๐—ฒ๐—ฟ๐˜ƒ๐—ฒ๐—ฟ ๐—ข๐—ฏ๐—ท๐—ฒ๐—ฐ๐˜ ๐—˜๐˜…๐—ฝ๐—น๐—ผ๐—ฟ๐—ฒ๐—ฟ.
  2. Right-click ๐—”๐˜‡๐˜‚๐—ฟ๐—ฒ > ๐—”๐—ฑ๐—ฑ ๐—”๐˜‡๐˜‚๐—ฟ๐—ฒ ๐—”๐—ฐ๐—ฐ๐—ผ๐˜‚๐—ป๐˜ and sign in.
  3. Right-click your ๐—”๐˜‡๐˜‚๐—ฟ๐—ฒ ๐˜€๐˜‚๐—ฏ๐˜€๐—ฐ๐—ฟ๐—ถ๐—ฝ๐˜๐—ถ๐—ผ๐—ป > ๐—ฆ๐—ค๐—Ÿ ๐—ฆ๐—ฒ๐—ฟ๐˜ƒ๐—ฒ๐—ฟ๐˜€ > ๐—”๐—ฑ๐—ฑ ๐—ฆ๐—ค๐—Ÿ ๐—ฆ๐—ฒ๐—ฟ๐˜ƒ๐—ฒ๐—ฟ.
  4. Create a new ๐—ฆ๐—ค๐—Ÿ ๐—ฆ๐—ฒ๐—ฟ๐˜ƒ๐—ฒ๐—ฟ ๐—ฎ๐—ป๐—ฑ ๐——๐—ฎ๐˜๐—ฎ๐—ฏ๐—ฎ๐˜€๐—ฒ.
  • Choose ๐—™๐—ฟ๐—ฒ๐—ฒ ๐—ง๐—ถ๐—ฒ๐—ฟ if available.
  • Note the ๐˜€๐—ฒ๐—ฟ๐˜ƒ๐—ฒ๐—ฟ ๐—ป๐—ฎ๐—บ๐—ฒ, ๐—ฎ๐—ฑ๐—บ๐—ถ๐—ป ๐˜‚๐˜€๐—ฒ๐—ฟ๐—ป๐—ฎ๐—บ๐—ฒ & ๐—ฝ๐—ฎ๐˜€๐˜€๐˜„๐—ผ๐—ฟ๐—ฑ.

๐—ฆ๐˜๐—ฒ๐—ฝ ๐Ÿฏ: ๐——๐—ฒ๐—ฝ๐—น๐—ผ๐˜† ๐—Ÿ๐—ผ๐—ฐ๐—ฎ๐—น ๐——๐—ฎ๐˜๐—ฎ๐—ฏ๐—ฎ๐˜€๐—ฒ ๐˜๐—ผ ๐—”๐˜‡๐˜‚๐—ฟ๐—ฒ

  1. In ๐—ฆ๐—ค๐—Ÿ ๐—ฆ๐—ฒ๐—ฟ๐˜ƒ๐—ฒ๐—ฟ ๐—ข๐—ฏ๐—ท๐—ฒ๐—ฐ๐˜ ๐—˜๐˜…๐—ฝ๐—น๐—ผ๐—ฟ๐—ฒ๐—ฟ, right-click your ๐—น๐—ผ๐—ฐ๐—ฎ๐—น ๐——๐—• > ๐—ฃ๐˜‚๐—ฏ๐—น๐—ถ๐˜€๐—ต ๐˜๐—ผ ๐—”๐˜‡๐˜‚๐—ฟ๐—ฒ.
  2. Choose the Azure SQL Server you created.
  3. Review settings > Click ๐—ฃ๐˜‚๐—ฏ๐—น๐—ถ๐˜€๐—ต.
  • It creates tables, schemas, and data in Azure SQL.

๐—ฆ๐˜๐—ฒ๐—ฝ ๐Ÿฐ: ๐—จ๐—ฝ๐—ฑ๐—ฎ๐˜๐—ฒ ๐—–๐—ผ๐—ป๐—ป๐—ฒ๐—ฐ๐˜๐—ถ๐—ผ๐—ป ๐—ฆ๐˜๐—ฟ๐—ถ๐—ป๐—ด ๐—ถ๐—ป ๐—ฎ๐—ฝ๐—ฝ๐˜€๐—ฒ๐˜๐˜๐—ถ๐—ป๐—ด๐˜€.๐—ท๐˜€๐—ผ๐—ป

Replace local DB connection with the Azure one:

"ConnectionStrings": {
"DefaultConnection": "Server=tcp:.database.windows.net,1433;Initial Catalog=;Persist Security Info=False;User ID=;Password=;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
}

๐—ฆ๐˜๐—ฒ๐—ฝ ๐Ÿฑ: ๐——๐—ฒ๐—ฝ๐—น๐—ผ๐˜† ๐—”๐—ฆ๐—ฃ.๐—ก๐—˜๐—ง ๐—–๐—ผ๐—ฟ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ท๐—ฒ๐—ฐ๐˜ ๐˜๐—ผ ๐—”๐˜‡๐˜‚๐—ฟ๐—ฒ

  • Right-click the project > ๐—ฃ๐˜‚๐—ฏ๐—น๐—ถ๐˜€๐—ต.
  • Choose ๐—”๐˜‡๐˜‚๐—ฟ๐—ฒ ๐—”๐—ฝ๐—ฝ ๐—ฆ๐—ฒ๐—ฟ๐˜ƒ๐—ถ๐—ฐ๐—ฒ, sign in, and create App Service if needed.
  • Publish the app.

Now your ASP.NET Core app is live on Azure and connected to ๐—”๐˜‡๐˜‚๐—ฟ๐—ฒ ๐—ฆ๐—ค๐—Ÿ ๐——๐—ฎ๐˜๐—ฎ๐—ฏ๐—ฎ๐˜€๐—ฒ.

๐—›๐—ฎ๐˜ƒ๐—ฒ ๐˜†๐—ผ๐˜‚ ๐—ฒ๐˜ƒ๐—ฒ๐—ฟ ๐˜๐—ฟ๐—ถ๐—ฒ๐—ฑ ๐—ฑ๐—ฒ๐—ฝ๐—น๐—ผ๐˜†๐—ถ๐—ป๐—ด ๐˜†๐—ผ๐˜‚๐—ฟ ๐—น๐—ผ๐—ฐ๐—ฎ๐—น ๐——๐—• ๐˜๐—ผ ๐—”๐˜‡๐˜‚๐—ฟ๐—ฒ ๐—ฎ๐—น๐—ผ๐—ป๐—ด ๐˜„๐—ถ๐˜๐—ต ๐˜๐—ต๐—ฒ ๐—ฎ๐—ฝ๐—ฝ? ๐—ช๐—ต๐—ฎ๐˜ ๐˜๐—ถ๐—ฝ๐˜€ ๐—ผ๐—ฟ ๐—ฐ๐—ต๐—ฎ๐—น๐—น๐—ฒ๐—ป๐—ด๐—ฒ๐˜€ ๐˜„๐—ผ๐˜‚๐—น๐—ฑ ๐˜†๐—ผ๐˜‚ ๐˜€๐—ต๐—ฎ๐—ฟ๐—ฒ ๐˜„๐—ถ๐˜๐—ต ๐—ผ๐˜๐—ต๐—ฒ๐—ฟ๐˜€?

Top comments (0)