How to delete files in Azure kudu after the deployment ? I wrote some Powershell script using Azure app service deploy task after the deployment using post deployment action step but I couldn't able to delete the files.
I have simple-test.log and simeple.txt files exist in azure kudu.Please help me to solve this issue.
Script:
if((Test-Path 'D:\home\site\wwwroot'))
{
rm simple*
Write-Host "Simple log file is exist,removed"
}
KUDU Log:
KUDU LOG FILES
Deployment Log Snap
using kudu you would need to put it under site\deployments\tools\PostDeploymentActions. then kudu will run it after every deployment automatically. All the ps1, bat, cmd under that directory would be run by kuku
you can also put it to a custom directory, but you'd need to tell kudu where to get it by setting this setting: SCM_POST_DEPLOYMENT_ACTIONS_PATH.
Reading: https://github.com/projectkudu/kudu/wiki/Post-Deployment-Action-Hooks
Related
I am using CloudShell to publish AzureFunction. I was able to publish the AzureFunction previously but today I am getting this Error while executing the publish command func azure functionapp publish <APP_NAME>
Getting site publishing info...
Creating archive for current directory...
Performing remote build for functions project. Deleting the old .python_packages directory Uploading 15.91 KB [##############################################################################]
Remote build in progress, please wait...
Unexpected character encountered while parsing value: {. Path '[0].build_summary', line 1, position 630.
When i put my war file on D:\home\site\wwwroot\webapps and restart my app, no directory are create
Do you have some solutions ?
Logs of deployment:
2021-03-22T11:42:58.0110686Z,Updating submodules.,1bd3e5b1-47f2-46ce-9457-f22ade6578aa,0
2021-03-22T11:42:58.0891711Z,Preparing deployment for commit id 'c6e8c194dd'.,0e358782-a7e2-489c-a948-8d092e2167bb,0
2021-03-22T11:42:58.3235865Z,Generating deployment script.,f5b0c67e-46f7-462d-8910-d82e86d2d6ca,0
2021-03-22T11:42:58.3704629Z,Using cached version of deployment script (command: 'azure -y --no-dot-deployment -r "D:\home\site\repository" -o "D:\home\site\deployments\tools" --basic --sitePath "D:\home\site\repository"').,,0
2021-03-22T11:42:58.4016684Z,Running deployment command...,c4320046-f4d1-4886-8e7b-bd831740e0d4,0
2021-03-22T11:42:58.4172963Z,Command: "D:\home\site\deployments\tools\deploy.cmd",,0
2021-03-22T11:42:59.9329442Z,Handling Basic Web Site deployment.,,0
2021-03-22T11:43:01.1360454Z,Creating app_offline.htm,,0
2021-03-22T11:43:01.1516687Z,KuduSync.NET from: 'D:\home\site\repository' to: 'D:\home\site\wwwroot',,0
2021-03-22T11:43:01.1516687Z,Copying file: 'bin\apache-tomcat-8.0.33\webapps\sapws.war',,0
2021-03-22T11:43:01.1672937Z,Deleting app_offline.htm,,0
2021-03-22T11:43:01.1672937Z,Finished successfully.,,0
2021-03-22T11:43:01.2297946Z,Running post deployment command(s)...,24cd4f28-8e09-4dd3-884f-7a78ac72e1cb,0
2021-03-22T11:43:01.3079454Z,Triggering recycle (preview mode disabled).,24b334b7-e6c1-428f-a9ac-d91f039188c6,0
2021-03-22T11:43:01.4172916Z,Deployment successful.,9512433d-cee0-45c2-a8fe-4bf173281d0b,0
You can use the method in my gif to test and deploy.
You also can use below way to deploy webapp.
Deploy your app to Azure App Service with a ZIP or WAR file
I use pretty much standard custom kudu deployment script for asp.net core web app for external git deployment.
I managed to run the script mostly successfully, through mingling with SCM_COMMAND_IDLE_TIMEOUT and .cmd files encoding. My deployment scripts look as follows:
.deployment
[config]
command = deploy.cmd
deploy.cmd
#echo off
IF "%WEBSITE_SITE_TYPE%" == "<project_name>" (
.\<project folder>\Properties\deploy.cmd
goto end
)
echo Unknown WEBSITE_SITE_TYPE: "%WEBSITE_SITE_TYPE%". Expected one of the "<project name>"
:end
exit /b
.\<project folder>\Properties\deploy.cmd - regular asp.net core deploy.cmd script, updated for proper folder structure.
The WEBSITE_SITE_TYPE is a custom environment variable I added to the web app.
All these scripts saved with utf-8 without BOM encoding.
But even though the scripts look like runs successfully, the final state of the deployment process is Failed.
When looking into the kudu deployment log last few lines of the log look as follows:
...
2018-10-14T20:50:51.0660695Z,Copying file: 'wwwroot\runtime.ec2944dd8b20ec099bf3.js',,0
2018-10-14T20:50:51.0660695Z,Copying file: 'wwwroot\styles.8ef9ef86d2a54ed3748c.css',,0
2018-10-14T20:50:51.0816988Z,Deleting app_offline.htm,,0
2018-10-14T20:50:51.0816988Z,Finished successfully.,,0
2018-10-14T20:50:51.1129431Z,\r\nD:\Program Files (x86)\SiteExtensions\Kudu\78.11002.3584\bin\Scripts\starter.cmd deploy.cmd,,2
Apparently the last line returns error code 2 and it might cause the script status to fail. But what does it mean and how do I fix it?
I had Composer Site extension installed till now on azure php webapp.
I need custom deployment that can run grunt tasks also. So I created the .deployment and deploy.sh files in project root. But that deploy.sh is not being picked up.
.deployment file contents:
[config]
command = bash deploy.sh
Looking at the deployment logs, I find this
2017-05-04T06:21:03.9301086Z,Updating submodules.,8bc3029f-d77b-4c1e-860f-a3d439d7a354,0
2017-05-04T06:21:03.9926050Z,Preparing deployment for commit id 'e2b45fb52b'.,61c286b1-5c00-4c11-ae14-54e0711d6857,0
2017-05-04T06:21:04.2632947Z,Running custom deployment command...,e71c397e-bc63-4357-abc4-acd49bc2041d,0
2017-05-04T06:21:04.3101663Z,Running deployment command...,24db1c4f-8a51-463b-8c4a-ee040bc5dfd8,0
2017-05-04T06:21:04.3101663Z,Command: D:\home\SiteExtensions\ComposerExtension\Hooks\deploy.cmd,,0
2017-05-04T06:21:04.4039215Z,The system cannot find the path specified.,,1
2017-05-04T06:21:04.4195462Z,The system cannot find the path specified.\r\nD:\Program Files (x86)\SiteExtensions\Kudu\62.60430.2807\bin\Scripts\starter.cmd D:\home\SiteExtensions\ComposerExtension\Hooks\deploy.cmd,,2
Seems like somewhere the trigger for Composer site extension still remains which is being invoked during deployment.
How can I completely remove Composer site extension and use my custom deployment script deploy.sh? Thanks in advance.
Found the problem. After uninstalling Composer SiteExtension, this environment variable is still present APPSETTING_COMMAND = D:\home\SiteExtensions\ComposerExtension\Hooks\deploy.cmd. Deleted the environment variable using kudu console and then deployment succeeded.
After removing the Composer Extension the APPSETTING_COMMAND remains as an environment variable.
Use the Kudu PowerShell command Remove-Item Env:\APPSETTING_COMMAND to remove the variable online.
Alternatively, restarting the App Service via the overview tab will refresh the environment variables, though this could be a little invasive.
I have 2 Azure App Service Deploy steps in a Team Services build, they have the same Subscription details. The only difference is that they target different virtual applications - the one that fails contains an é character, could that be the cause? Here the step output:
2017-01-17T16:04:22.8323742Z 8570d8e4-b732-4c45-87c5-619fe9343427 exists true
2017-01-17T16:04:24.5778681Z Got connection details for Azure App Service:'foo'
2017-01-17T16:04:24.6088690Z Running command: "C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:getParameters -source:package="C:\a\1\a\Foo.zip" > "C:\a\1\s\parameter.xml"
2017-01-17T16:04:25.4027522Z Running command: #echo off
2017-01-17T16:04:25.4027522Z "C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -source:package="C:\a\1\a\Foo.zip" -dest:auto,ComputerName='https://foo.scm.azurewebsites.net:443/msdeploy.axd?site=foo',UserName='********',Password='********',AuthType='Basic' -setParam:name='IIS Web Application Name',value='foo/bar-é' -userAgent:VSTS_foo_build_154_744 2>error.txt
2017-01-17T16:04:25.4027522Z if %errorlevel% neq 0 exit /b %errorlevel%
2017-01-17T16:04:25.4067519Z [command]C:\Windows\system32\cmd.exe /C C:\a\1\s\msDeployCommand.bat
2017-01-17T16:04:25.4157662Z 'C:\Program' is not recognized as an internal or external command,
2017-01-17T16:04:25.4167533Z operable program or batch file.
2017-01-17T16:04:25.4207534Z ##[error]Failed to deploy App Service.
2017-01-17T16:04:29.2496923Z ##[error]Error: Error: C:\Windows\system32\cmd.exe failed with return code: 9009
2017-01-17T16:04:29.2576899Z ##[section]Finishing: Azure App Service Deploy: foo-dev-global
It's almost as if the Powershell command itself is broken, I'm guessing by the special character.
It maybe not the special character causes that issue. I try to deploy the virtual Application with the special characters é , following is my detail steps. Hope it is useful. We also can get moreinfo about WebDeploy error code please refer to document.
1.Create a new build definition for the project
2.Select build solution corresponding VS version.
Before config Azure App Service Deployment, we need to create a WebApp in the Azure portal and the edit the appsetting to add the
Virtual applications info
Config the Azure App Service Deployment with service name and Virtual application created in the step3
5.New Queue build for the build definition
Then we can check that it deployed successfully from deployment log or from kudu.
This is now working as expected, without me making any changes. Having informed MS of the issue, I can only conclude they've released a fix to the build task.