You can try to use Custom Deployment Script to execute additional scripts or command during the deployment task. So you can create a php script whose functionality is to download the certificate files from Blob Storage to server file system location. And then in your PHP application, the DB connection can use these files.
Following are the general steps:
- Enable
composer
extension in your portal:
- Install
azure-cli
module via npm
, refer to https://docs.microsoft.com/en-us/azure/xplat-cli-install for more info.
- Create deployment script for php via command
azure site deplotmentscript --php
- Execute command
composer require microsoft/windowsazure
, make sure you have a composer.json
with the storage sdk dependency.
-
Create php script in your root directory to download flies from Blob Storage(e.g. named run.php
):
require_once 'vendor/autoload.php';
use WindowsAzure\Common\ServicesBuilder;
use MicrosoftAzure\Storage\Common\ServiceException;
$connectionString = "<connection_string>";
$blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString);
$container = 'certificate';
$blobs = ['client-key.pem','client-cert.pem','cleardb-ca.pem'];
foreach($blobs as $k => $b){
$blobresult = $blobRestProxy->getBlob($container, $b);
$source = stream_get_contents($blobresult->getContentStream());
$result = file_put_contents($b, $source);
}
- Modify the
deploy.cmd
script, add santence php run.php
under the step KuduSync
.
- Deploy your application to Azure Web App via Git.
Any further concern, please feel free to let me know.