locked
SQL Server Database RRS feed

  • Question

  • User-305496339 posted

    I have a .Net Core application that is using a SQL Server Database. I know how to deploy a project or application to Azure that's not using a database. But what if I want to deploy an application that is using a sql server database. Do I create a SQL Server Database on Azure and then connect to it? If so what happens to all of my existing connectionstring settings in the web.config file? Thanks !

    Thursday, June 28, 2018 6:23 PM

Answers

  • User2053451246 posted

    rkrex

    Do I create a SQL Server Database on Azure and then connect to it?

    Yes.  You will have a server address available in the Azure portal that you use in SSMS on your local machine to connect to SQL Server on Azure.  You can either backup your database and restore it to Azure or script it all and run that script on Azure.

    rkrex

    If so what happens to all of my existing connectionstring settings in the web.config file?

    Use Web.config transforms: https://msdn.microsoft.com/en-us/library/dd465326%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396

    <?xml version="1.0" encoding="utf-8"?>
    <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
      <connectionStrings xdt:Transform="Replace">
        <clear />
        <add name="YOUR_CONNECTION_STRING_NAME" connectionString="Data Source=YOUR_AZURE_SERVER_NAME;Initial Catalog=YOUR_DATABASE_NAME;Integrated Security=True;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />
      </connectionStrings>
      <system.web>
        <compilation xdt:Transform="RemoveAttributes(debug)" />
      </system.web>
    </configuration>

    EDIT: Right-click the Web.config file in your project and you will see the choice "Add Config Transform" on the popup menu.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 28, 2018 7:46 PM

All replies

  • User2053451246 posted

    rkrex

    Do I create a SQL Server Database on Azure and then connect to it?

    Yes.  You will have a server address available in the Azure portal that you use in SSMS on your local machine to connect to SQL Server on Azure.  You can either backup your database and restore it to Azure or script it all and run that script on Azure.

    rkrex

    If so what happens to all of my existing connectionstring settings in the web.config file?

    Use Web.config transforms: https://msdn.microsoft.com/en-us/library/dd465326%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396

    <?xml version="1.0" encoding="utf-8"?>
    <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
      <connectionStrings xdt:Transform="Replace">
        <clear />
        <add name="YOUR_CONNECTION_STRING_NAME" connectionString="Data Source=YOUR_AZURE_SERVER_NAME;Initial Catalog=YOUR_DATABASE_NAME;Integrated Security=True;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />
      </connectionStrings>
      <system.web>
        <compilation xdt:Transform="RemoveAttributes(debug)" />
      </system.web>
    </configuration>

    EDIT: Right-click the Web.config file in your project and you will see the choice "Add Config Transform" on the popup menu.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 28, 2018 7:46 PM
  • User-305496339 posted

    Thanks very Much !

    Thursday, June 28, 2018 9:22 PM