dqan70724 2017-02-07 06:12
浏览 52

如何在microsoft AZURE服务器(PaaS)中安装msodbcsql

Okay, so basically I have now deployed an Web App in Azure, but I cannot seem to make it to connect to a separate SQL SERVER. I have provided all the desired App settings for the connection but it seems no good.

Now I search for possible causes:

  1. PHP ext dlls are missing for msodbcsql which are

php_pdo_sqlsrv_56_ts.dll and php_sqlsrv_56_ts.dll

I already added this dll's and referenced them accordingly base on this document Configure via ini settings

  1. Now the uncertainty that msodbcsql is installed in Azure.

Now this is what I am having problem with.

So in my case in number 2 I tried copying the installer to Azure D:/home/

and run this in the command line

msiexec /quiet /passive /qn /i msodbcsql.msi IACCEPTMSODBCSQLLICENSETERMS=YES ADDLOCAL=ALL

which is suppose to install the .msi installer but i always get an

ACCESS IS DENIED

error.

is there another way around??

  • 写回答

1条回答 默认 最新

  • doudizhi947129 2017-02-07 09:12
    关注

    Basically Azure has already set up extension php_sqlsrv.dll & php_pdo_sqlsrv.dll for us, so we ourselves do not need to install any driver to connect SQL SERVER.

    You could check the php.ini file which can be found at D:\local\Config\PHP-<version>\php.ini with Kudu console to confirm that.

    enter image description here

    Also, you can check that with phpinfo() function in your application.

    enter image description here enter image description here

    And I have tested it with the following lines of code and got it worked.

    <?php
    $serverName = "serverName\sqlexpress"; //serverName\instanceName
    $connectionInfo = array( "Database"=>"dbName", "UID"=>"userName", "PWD"=>"password");
    $conn = sqlsrv_connect( $serverName, $connectionInfo);
    
    if( $conn ) {
         echo "Connection established.<br />";
    }else{
         echo "Connection could not be established.<br />";
         die( print_r( sqlsrv_errors(), true));
    }
    ?>
    

    enter image description here

    评论

报告相同问题?