AppService側で設定した値でアクセス

wp-config.phpを書き換え

<?php
if(!isset($_SERVER["MYSQLCONNSTR_localdb"])) throw new Exception('MYSQLCONNSTR ENV is not defined');

$azure_mysql_connstr = $_SERVER["MYSQLCONNSTR_localdb"];
$azure_mysql_connstr_match = preg_match(
  "/".
    "Database=(?<database>.+);".
    "Data Source=(?<datasource>.+):".
    "(?<port>.+);".
    "User Id=(?<userid>.+);".
    "Password=(?<password>.+)".
  "/u",
  $azure_mysql_connstr,
  $_);

if($azure_mysql_connstr_match === false) throw new Exception('Could not parse for MYSQLCONNSTR ENV');

$db_settings = [
    'host'      => $_['datasource'],
    'port'      => $_['port'],
    'database'  => $_['database'],
    'username'  => $_['userid'],
    'password'  => $_['password'],
];

var_dump($db_settings);
?>
Last modified: 2020-05-27