syntaxc4-msft / composerextension Goto Github PK
View Code? Open in Web Editor NEWBrings Composer Support to Azure Websites via a Site Extension
Home Page: http://www.siteextensions.net
License: MIT License
Brings Composer Support to Azure Websites via a Site Extension
Home Page: http://www.siteextensions.net
License: MIT License
Is is possible to add support for Composer 2?
I noticed Azure is running v1.8.5. I found this out by going to Azure Portal → App Service → advanced tools → debug console → CMD:
D:\home>composer --version
Composer version 1.8.5 2019-04-09 17:46:47
Thanks!
When using Local Git method for deployment, composer install
frequently fails to install updates on deployment
remote: Updating branch 'master'.
remote: Updating submodules.
remote: Preparing deployment for commit id '9822aac992'.
remote: Running custom deployment command...
remote: Running deployment command...
remote: Install Dependencies with Composer
remote: Installing dependencies from lock file
remote: Verifying lock file contents can be installed on current platform.
remote: Package operations: 0 installs, 2 updates, 0 removals
remote: - Downloading symfony/translation (v5.2.2)
remote: - Downloading nesbot/carbon (2.44.0)
remote: - Upgrading symfony/translation (v5.2.1 => v5.2.2): Extracting archive
remote: Update of symfony/translation failed
remote: ......
remote: - Upgrading nesbot/carbon (2.43.0 => 2.44.0): Extracting archive
remote: Update of nesbot/carbon failed
remote:
remote:
remote: [RuntimeException]
remote: Could not delete D:\home\site\repository/vendor/composer/tmp-76b8eabe55017bfdfc0c60d8931c3967:
remote: This can be due to an antivirus or the Windows Search Indexer locking the file while they are analyzed
remote:
remote:
remote: An error has occurred during web site deployment.
Need to ask @davidebbo about how we can make a safe rewrite rule that will play nicely with kudu.
Otherwise, there will be duplicate sections. https://github.com/SyntaxC4-MSFT/ComposerExtension/blob/master/Content/applicationHost.xdt#L12
Now that the COMPOSER_VENDOR_DIR points out side of the wwwroot directory it drops files to the vendor folder, instead of dropping the files into the folder which was defined for creation.
We are using VSTS for deployment on azure via FTP/S task. In our web app, composer does not run automatically and need to be updated manually from azure. Is there a way to automate this process?
https://docs.microsoft.com/en-us/azure/app-service-web/app-service-deploy-ftp
I have encountered an issue today where Composer failed part way through retrieving dependencies. However, the partially downloaded dependencies were then copied across to the live site, which resulted in an outage.
Currently, the deploy.cmd file does not check for an error before calling the Kudu sync command:
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Download Dependencies with Composer
:: -----------------
echo Install Dependencies with Composer
call composer install %COMPOSER_ARGS%
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Deployment
:: ----------
echo Handling Basic Web Site deployment.
:: 1. KuduSync
call %KUDU_SYNC_CMD% -v 50 -f "%DEPLOYMENT_SOURCE%" -t "%DEPLOYMENT_TARGET%" -n "%NEXT_MANIFEST_PATH%" -p "%PREVIOUS_MANIFEST_PATH%" -i ".git;.hg;.deployment;deploy.cmd"
IF !ERRORLEVEL! NEQ 0 goto error
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Adding IF !ERRORLEVEL! NEQ 0 goto error
after the call composer install %COMPOSER_ARGS%
line will prevent this from happening.
Azure does not auto-load PHP binary extensions (such as LDAP). The user must upload their own copy of the binary (compatible for the configured version of PHP) and then either alter the website settings to load it or upload a custom .user.ini file specifying the extension=D:\path\to\wwwroot\somedir\extension.dll
Some composer install commands fail (such as Adldap/Adldap) if the interpreter running composer does not have the binary extension required for the library to operate loaded, even if the IIS invoked PHP interpreter does.
I ended up editing my deploy script to -dextension=D:\path\blah\my.dll and that resolved it temporarily however does not autoload additional libraries if the website variable or .user.ini file is updated. Is there any way the default composer extension can attempt to load additional configuration files to avoid this issue?
Hi!
I find this extension the must for every php developer willing to deploy on Azure Site, but I'm finding some problems with dependencies: sometimes happens that a dependency could not be find under git and composer tries with SVN. In this case the deployment process is being flagged as successful but it actually isn't, 'cause Azure Site doesn't support the svn command.
Have you any ideas on how to introduce the svn command?
Thanks!
This wasn't a problem with the extension Cory, rather a wrong approach of doing things from my side.
Hi there,
I've been trying to install this extension via an ARM deployment template. I can get this to work fine with other extensions such as in this example:
But when I provide the value such as:
"resources": [
{
"apiVersion": "2015-08-01",
"name": "ComposerExtension",
"type": "siteextensions",
"dependsOn": [
"[variables('appName')]"
],
"properties": {
"version": "0.5.3",
"feed_url": "https://www.siteextensions.net/api/v2/"
}
}
]
I get an error saying that "ComposerExtension" could not be found. Any ideas why this is the case?
Please see Azure/app-service-announcements#87 for detailed announcement.
Important: if your site extension is still relevant, you need to do this before June 1st 2018. Please let me know if you have any questions.
Thanks!
After removing the extension from my Web App, I have to manually reset the COMMAND environment variable back to default on my Web App.
Urls such as these are getting blocked:
http://katana.azurewebsites.net/static/vendor/event-source-polyfill/eventsource.min.js
And also in the kudu console. Let me know if you need additional info.
To reproduce, you can install (sabre/katana)[http://github.com/fruux/sabre-katana], and:
public/
.composer install
npm install
bower install --production
Hi,
It looks like my custom deployment script is not running when this extension is installed.
I've got .deployment and deploy.cmd files in root of my repo.
During deployment only Composer deployment command is running.
After Composer extension deinstallation, custom script is running fine (except error about missing composer component)
.deployment
[config]
command = deploy.cmd
deploy.cmd
@if "%SCM_TRACE_LEVEL%" NEQ "4" @echo off
:: ----------------------
:: KUDU Deployment Script
:: Version: 1.0.6
:: ----------------------
:: Prerequisites
:: -------------
:: Verify node.js installed
where node 2>nul >nul
IF %ERRORLEVEL% NEQ 0 (
echo Missing node.js executable, please install node.js, if already installed make sure it can be reached from current environment.
goto error
)
:: Setup
:: -----
setlocal enabledelayedexpansion
SET ARTIFACTS=%~dp0%..\artifacts
IF NOT DEFINED DEPLOYMENT_SOURCE (
SET DEPLOYMENT_SOURCE=%~dp0%.
)
IF NOT DEFINED DEPLOYMENT_TARGET (
SET DEPLOYMENT_TARGET=%ARTIFACTS%\wwwroot
)
IF NOT DEFINED NEXT_MANIFEST_PATH (
SET NEXT_MANIFEST_PATH=%ARTIFACTS%\manifest
IF NOT DEFINED PREVIOUS_MANIFEST_PATH (
SET PREVIOUS_MANIFEST_PATH=%ARTIFACTS%\manifest
)
)
IF NOT DEFINED KUDU_SYNC_CMD (
:: Install kudu sync
echo Installing Kudu Sync
call npm install kudusync -g --silent
IF !ERRORLEVEL! NEQ 0 goto error
:: Locally just running "kuduSync" would also work
SET KUDU_SYNC_CMD=%appdata%\npm\kuduSync.cmd
)
goto Deployment
:: Utility Functions
:: -----------------
:SelectNodeVersion
IF DEFINED KUDU_SELECT_NODE_VERSION_CMD (
:: The following are done only on Windows Azure Websites environment
call %KUDU_SELECT_NODE_VERSION_CMD% "%DEPLOYMENT_SOURCE%" "%DEPLOYMENT_TARGET%" "%DEPLOYMENT_TEMP%"
IF !ERRORLEVEL! NEQ 0 goto error
IF EXIST "%DEPLOYMENT_TEMP%\__nodeVersion.tmp" (
SET /p NODE_EXE=<"%DEPLOYMENT_TEMP%\__nodeVersion.tmp"
IF !ERRORLEVEL! NEQ 0 goto error
)
IF EXIST "%DEPLOYMENT_TEMP%\__npmVersion.tmp" (
SET /p NPM_JS_PATH=<"%DEPLOYMENT_TEMP%\__npmVersion.tmp"
IF !ERRORLEVEL! NEQ 0 goto error
)
IF NOT DEFINED NODE_EXE (
SET NODE_EXE=node
)
SET NPM_CMD="!NODE_EXE!" "!NPM_JS_PATH!"
) ELSE (
SET NPM_CMD=npm
SET NODE_EXE=node
)
goto :EOF
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Deployment
:: ----------
:Deployment
echo Handling deployment.
:: 1. Install composer packages
call composer install %COMPOSER_ARGS%
:: 3. Select node version
call :SelectNodeVersion
:: 4. Install npm packages
IF EXIST "%DEPLOYMENT_TARGET%\package.json" (
pushd "%DEPLOYMENT_TARGET%"
echo Running NPM Install
call :ExecuteCmd !NPM_CMD! install
IF !ERRORLEVEL! NEQ 0 goto error
popd
)
:: 5. Run gulp transformations
IF EXIST "%DEPLOYMENT_TARGET%\gulpfile.js" (
pushd "%DEPLOYMENT_TARGET%"
echo Running Gulp Task
call :ExecuteCmd .\node_modules\.bin\gulp
IF !ERRORLEVEL! NEQ 0 goto error
popd
)
:: 2. KuduSync
IF /I "%IN_PLACE_DEPLOYMENT%" NEQ "1" (
call :ExecuteCmd "%KUDU_SYNC_CMD%" -v 50 -f "%DEPLOYMENT_SOURCE%" -t "%DEPLOYMENT_TARGET%" -n "%NEXT_MANIFEST_PATH%" -p "%PREVIOUS_MANIFEST_PATH%" -i ".git;.hg;.deployment;deploy.cmd"
IF !ERRORLEVEL! NEQ 0 goto error
)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Post deployment stub
IF DEFINED POST_DEPLOYMENT_ACTION call "%POST_DEPLOYMENT_ACTION%"
IF !ERRORLEVEL! NEQ 0 goto error
goto end
:: Execute command routine that will echo out when error
:ExecuteCmd
setlocal
set _CMD_=%*
call %_CMD_%
if "%ERRORLEVEL%" NEQ "0" echo Failed exitCode=%ERRORLEVEL%, command=%_CMD_%
exit /b %ERRORLEVEL%
:error
endlocal
echo An error has occurred during web site deployment.
call :exitSetErrorLevel
call :exitFromFunction 2>nul
:exitSetErrorLevel
exit /b 1
:exitFromFunction
()
:end
endlocal
echo Finished successfully.
When I try to run composer from debug console or KuduExec I got the following error:
'composer' is not recognized as an internal or external command, operable program or batch file
When deploying the example source code from GitHub, I end up getting following error (WAWS Composer site extension enabled):
Command: d:\home\SiteExtensions\ComposerExtension\Hooks\deploy.cmd
Using custom deployment setting for DEPLOYMENT_SOURCE custom value is 'web'.
Install Dependencies with Composer
Loading composer repositories with package information
Initializing PEAR repository http://pear.php.net
Installing dependencies
- Installing pear-pear.php.net/mail_mime (1.8.9)
Downloading
- Installing pear-pear.php.net/mail_mimedecode (1.5.5)
Downloading
- Installing pear-pear.php.net/net_url2 (2.2.0)
Downloading
- Installing pear-pear.php.net/xml_util (1.3.0)
Downloading
- Installing pear-pear.php.net/console_getopt (1.4.0)
Downloading
- Installing pear-pear.php.net/structures_graph (1.1.0)
Downloading
- Installing pear-pear.php.net/archive_tar (1.3.16)
Downloading
- Installing pear-pear.php.net/pear (1.9.5)
Downloading
[UnexpectedValueException]
Fatal error: Uncaught exception 'Symfony\Component\Process\Exception\RuntimeException' with message 'Unable to kill the process' in phar://D:/home/SiteExtensions/ComposerExtension/Commands/composer.phar/vendor/symfony/process/Symfony/Component/Process/Process.php:803
Failed to extract PEAR package D:\home\site\vendor/pear-pear.php.net/PEAR/PEAR-1.9.5.tgz to D:\home\site\vendor/pear-pear.php.net/PEAR. Reason: Unable to kill the process
Stack trace:
#0 phar://D:/home/SiteExtensions/ComposerExtension/Commands/composer.phar/vendor/symfony/process/Symfony/Component/Process/Process.php(177): Symfony\Component\Process\Process->stop()
#1 [internal function]: Symfony\Component\Process\Process->__destruct()
#2 {main}
thrown in phar://D:/home/SiteExtensions/ComposerExtension/Commands/composer.phar/vendor/symfony/process/Symfony/Component/Process/Process.php on line 803
[Symfony\Component\Process\Exception\RuntimeException]
Unable to kill the process
install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-plugins] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [--ignore-platform-reqs] [packages1] ... [packagesN]
Handling Basic Web Site deployment.
KuduSync.NET from: 'D:\home\site\repository\web' to: 'D:\home\site\wwwroot'
Deleting file: 'hostingstart.html'
Copying file: 'index.php'
Finished successfully.
Another useful information could be probably Ran For: 400 seconds
This seems to me like composer is timing out - possibly by changing the Kudu timeout setting SCM_COMMAND_IDLE_TIMEOUT=600 (as per here), but I haven't tested this yet.
Could you look into this please?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.