1
votes

I'm working for an Azure project where the deployments can only be made using the ARM templates from Visual Studio CI and we have only read access to the Azure Portal.

Also I'm not use if I'm able to use Kudu as I can't access from Portal.

What I'm trying to do is overriding some PHP settings and enable some extra extensions for an Azure Web App. Using Kudu this is pretty easy but I can't figure out how I can upload two excluded file types .dlland .ini files during a release before web app deployment.

So far I tried below steps which made sense to me but apparently It's not working and a wrong approach. I would be glad if someone could guide me with the right steps.

I have set PHP_INI_SCAN_DIR=d:\home\site\ini as described in https://docs.microsoft.com/en-us/azure/app-service-web/web-sites-php-configure

I'm uploading the files with the below tasks and can see them uploaded in logs. I also tried to use paths with defined variables such as $(Agent.ReleaseDirectory) instead of absolute paths but it didn't change anything.

Release tasks

enter image description here

It seems PHP is looking d:\home\site\ini folder but can't find any ini file. Also the other options I have set, did not changed.

enter image description here

The content of the ini file;

; extensions.ini
; Enable Extensions
extension=d:\home\site\ext\php_redis.dll
; Settings
memory_limit = 256M
upload_max_filesize = 10M

UPDATE

Also the App Service deploy task,

enter image description here

And Virtual applications and directories from Application Settings

enter image description here

2
See extension_dir value? - "In what directory PHP should look for dynamically loadable extensions. See also: enable_dl, and dl(). " Not to be confused with php_ini_scan_dir. - ficuscr
Sorry, see I read that backwards. Have to ask, you restarted things after uploading the files? - ficuscr
Copy file tasks are before the app deploy. There shouldn't be need for restarting. Besides I cannot restart the app from portal. - Onur Kucukkece
What's the detail setting of Azure App Service Deploy task? What's the detail setting of app service's Virtual application and directories? (Open app service in azure portal> Application settings>Virtual application and directories) The Copy Files task just used to copy files on current machine (agent machine) - starian chen-MSFT
@starain-MSFT I've updated the question and attached screenshots. There is no other settings in Azure App Service Deploy task else than in the screenshot. - Onur Kucukkece

2 Answers

0
votes

The root path of Virtual Applications and directories is site\wwwroot, so all files will be deployed to the wwwroot folder if deploy web app through Azure App Service Deploy task.

You can upload specific files to corresponding folder (e.g. site\ini) through Kudu API before deploy app to azure app service.

Just refer to this thread to know how to use Kudu API in VSTS build: Remove files and foldes on Azure before a new deploy from VSTS.

Refer to this article to know how to upload a file to an app service: Interacting with Azure Web Apps Virtual File System using PowerShell and the Kudu API.

0
votes

Here is the approach I took for enabling the PHP extensions and configuring the PHP settings.

I gave up on trying setting everything in one ini file. For PHP settings I have created a .user.inifile in the root of the source code of the project and set the PHP options there.

; .user.ini
memory_limit = 256M
default_socket_timeout = 600
post_max_size = 64M
upload_max_filesize = 64M
max_execution_time = 1200
max_input_time = 1200

But If you have a file type filter on the build phases, adding *.ini or **/*.ini won't include the .user.ini file into the downloaded artifacts. So for this I've adjusted the build phase like below.

Build phases

For the PHP extension I have used PHP_EXTENSIONS environment variable. I have copied the DLL file to D:\home\site\ext using Copy File task and set PHP_EXTENSIONS=ext\php_redis.dll. See my tasks below.

Deployment tasks

Maybe it would be enough to put the Copy File task before the App Service Deploy tasks and wouldn't need to restart the app but I haven't tried it yet. For restarting the app I'm using Azure PowerShell with the following script written in a file.

Param(
    [string]$ResourceGroup,
    [string]$appName
)

Restart-AzureRmWebApp -ResourceGroupName $ResourceGroup -Name $appName | Out-Null
Write-Host "Started web app '$appName'"

Hope it helps someone else too.