All but first deployment of Orchard CMS to Azure Web Apps Fails - azure

In Visual Studio Online I have a scripted build that builds Orchard 1.9.1 from source then, using the Azure Web App Deployment task, deploys the compiled Web Deploy Package to Azure.
The first deployment to a fresh Web App instance works great and the system functions as expected. However, any subsequent deployment to the same Web App fails with:
Unable to perform the operation ("Delete File") for the specified
directory ("HtmlAgilityPack.dll"). This can occur if the server
administrator has not authorized this operation for the user
credentials you are using. Learn more at:
http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_INSUFFICIENT_ACCESS_TO_SITE_FOLDER.
The file specified in the error can be different, but the deployment fails consistently. The link in the error isn't of much help as the implementation details covered (IIS, root folder etc) are abstracted away in an Azure Web App.
Where should I look to fix this permissioning issue?
I went with the default build template for Azure Website when creating the build, details of which are below for info:
Build Step:
MSBuild Arguments:
/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true
/p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.stagingDirectory)"
Azure Web App Deployment step:
Pertinent information for the build log:
2015-09-28T05:36:22.7928424Z Package= C:\a\d8c9303e\staging\Orchard.Web.zip
2015-09-28T05:36:22.7938416Z Slot=
2015-09-28T05:36:22.7938416Z AdditionalArguments=
2015-09-28T05:36:22.8028415Z packageFile= Find-Files -SearchPattern C:\a\d8c9303e\staging\Orchard.Web.zip
2015-09-28T05:36:22.8198428Z packageFile= C:\a\d8c9303e\staging\Orchard.Web.zip
2015-09-28T05:36:22.8258420Z Get-AzureWebSite -Name **** -ErrorAction SilentlyContinue
2015-09-28T05:36:28.4361621Z Publish-AzureWebsiteProject -Name "****" -Package "C:\a\d8c9303e\staging\Orchard.Web.zip"
2015-09-28T05:36:33.8798112Z ##[error]Unable to perform the operation ("Delete File") for the specified directory ("HtmlAgilityPack.dll"). This can occur if the server administrator has not authorized this operation for the user credentials you are using.
2015-09-28T05:36:33.8818107Z ##[error] Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_INSUFFICIENT_ACCESS_TO_SITE_FOLDER.

Use the provided Orchard.proj msbuild script using the Precompiled target.

Related

GenerateEFSQLScripts fails when trying to publish to IIS using Web Deploy from TeamCity

Running into a total dead-end here.
I've created a Publish Profile for a .net6 application that we want to publish to IIS with Web Deploy. In the Entity Framework Migration section, the option to "Apply this migration on publish" is selected.
When manually clicking publish, everything works. However, we want to automate this in TeamCity using the .NET build runner. The publish step fails at:
Generating Entity Framework SQL Scripts...
Executing command: dotnet ef migrations script --no-build --idempotent --configuration Release --output "C:\TeamCity\buildAgent\work\cbf95cc2b4413601\MySolution.Api\obj\Release\net6.0\PubTmp\EFSQLScripts\MySolution.Data.MyContext.sql" --context MySolution.Data.MyContext
C:\Program Files\dotnet\sdk\6.0.400\Sdks\Microsoft.NET.Sdk.Publish\targets\TransformTargets\Microsoft.NET.Sdk.Publish.TransformFiles.targets(221,5): error : Entity Framework SQL Script generation failed
Internal error message details: BuildMessage1 0 Text DefaultMessage ERROR 400682522803500 tags:'tc:parseServiceMessagesInside'
Error message is logged
Build FAILED.
I cannot find any specific error messages anywhere in any log. Looking in the Microsoft.NET.Sdk.Publish.TransformFiles.targets file shows that it's failing on GenerateEFSQLScripts - an MSBuild command that executes dotnet ef under the covers.
I thought this might be a case of dotnet ef not being installed on the build agent. But when I manually run the command myself from C:\TeamCity\buildAgent\work\cbf95cc2b4413601\MySolution.Api, it succeeds, and the SQL scripts are successfully created.
I also thought it might just be a case of the command being run in the wrong directory (i.e. in the root MySolution folder rather than the MySolution.Api folder), but explicitly setting the working directly fails at the same point, with the same error.
Has anyone seen this before? Or could point me to where an actual error might be located?

Azure Deployment Pool Agent Fails to install IIS

Goal
I'm trying to install IIS on remote server using azure devops. I have done this on other vm servers without issue.
Problem
When running this stage the Agent Errors with very little details
Agent Errors when installing IIS
Error
2020-08-11T19:06:19.1822182Z ##[section]Starting: IIS Web App Manage
2020-08-11T19:06:19.1984662Z ==============================================================================
2020-08-11T19:06:19.1985052Z Task : IIS web app manage
2020-08-11T19:06:19.1985379Z Description : Create or update websites, web apps, virtual directories, or application pools
2020-08-11T19:06:19.1985671Z Version : 0.5.15
2020-08-11T19:06:19.1985908Z Author : Microsoft Corporation
2020-08-11T19:06:19.1986227Z Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/deploy/iis-web-app-management-on-machine-group
2020-08-11T19:06:19.1986625Z ==============================================================================
2020-08-11T19:06:21.2180244Z Installing IIS. This may take few minutes.
2020-08-11T19:06:46.1602426Z ##[error]The request to add or remove features on the specified server failed.
Installation of one or more roles, role services, or features failed.
The source files could not be found.
Use the "Source" option to specify the location of the files that are required to restore the feature. For more information on specifying a source location, see http://go.microsoft.com/fwlink/?LinkId=243077. Error: 0x800f081f
2020-08-11T19:06:46.1908491Z ##[section]Finishing: IIS Web App Manage
Stage Settings
steps:
- task: IISWebAppManagementOnMachineGroup#0
displayName: 'Manage IISWebsite'
inputs:
EnableIIS: true
WebsiteName: 'Default Web Site'
AddBinding: true
Bindings: '{"bindings":[{"protocol":"http","ipAddress":"All Unassigned","port":"80","hostname":"","sslThumbprint":"","sniFlag":false}]}'
CreateOrUpdateAppPoolForWebsite: true
AppPoolNameForWebsite: default
I solved this by stop trying to use the prebuilt IIS web app manage tool and ended up just installing iis via power shell command
Install-WindowsFeature -name Web-Server -IncludeManagementTools

Azure CD pipeline can't find build artifacts

Below is Azure error log from the Azure release pipeline.
2020-07-24T05:17:13.7712974Z ##[section]Starting: Deploy Azure App Service
2020-07-24T05:17:14.0464143Z ==============================================================================
2020-07-24T05:17:14.0465719Z Task : Azure App Service deploy
2020-07-24T05:17:14.0469391Z Description : Deploy to Azure App Service a web, mobile, or API app using Docker, Java, .NET, .NET Core, Node.js, PHP, Python, or Ruby
2020-07-24T05:17:14.0469849Z Version : 3.163.5
2020-07-24T05:17:14.0470410Z Author : Microsoft Corporation
2020-07-24T05:17:14.0470921Z Help : https://aka.ms/azureappservicetroubleshooting
2020-07-24T05:17:14.0471274Z =============================================================================
2020-07-24T05:17:16.0650643Z Got connection details for Azure App Service:'XXXXX'
2020-07-24T05:17:17.6576087Z (node:764) Warning: Use Cipheriv for counter mode of aes-256-ctr
**2020-07-24T05:17:17.6627737Z ##[error]Error: No package found with specified pattern: D:\a\r1\a\Drop<br/>Check if the package mentioned in the task is published as an artifact in the build or a previous stage and downloaded in the current job.**
2020-07-24T05:17:22.9168975Z Successfully added release annotation to the Application Insight : XXXXX
2020-07-24T05:17:24.8686063Z Successfully updated deployment History at https://XXXXX.scm.azurewebsites.net/api/deployments/231595567842919
2020-07-24T05:17:24.8933576Z ##[section]Finishing: Deploy Azure App Service
P.S. I have checked build pipeline, I can download build Artificats, but it displays below warning.
[warning]Directory 'D:\a\1\a' is empty. Nothing will be added to build artifact 'drop'.
Assuming you meant you have solved the build artifact empty issue, but the release pipeline still had issue in Azure App Service deploy task.
As the error mentioned, there is "No package found with specified pattern: D:\a\r1\a\Drop", you need to check how you define the package, try format $(System.DefaultWorkingDirectory)/**/*.zip instead of $(System.DefaultWorkingDirectory)\Drop.
As task "Publish Build Artifact" publish artifact from $(build.artifactstagingdirectory), so we need add a task "Copy files" to copy your files ** from $(system.defaultworkingdirectory) to $(build.artifactstagingdirectory) **. which copied my build to stagingdirectory.

Site cannot be loaded when using Deploy to Web app from VS Code

At work I'm using Visual Studios 2019 to publish my ASP.Net Core 2.1 App to the Azure App Service. At home I run a linux maschine and use VS Code to work on the project. Now I'm having trouble to deploy the app to Azure using 'Deploy to Web App' in VS Code. The process finishes successfully but when I open the url I get an 'IIS 502.5 Error - Process Failure'. Using Visual Studio this does not happen.
Before deploying the app I tried to build it using
dotnet build -c Release
with no success. I also tried
dotnet publish -c Release -f netcoreapp2.1 --no-self-contained
with no success too. Both commands followed by 'Deploy to Web App'.
Am I doing something wrong or do I miss some build-option?
Got it myself. Found the solution here.
You just have to set the deploySubpath to the directory where dotnet publish puts the generated files. In my case I had to set it to project_1/bin/Release/netcoreapp2.1/publish, which will be created by the command dotnet publish -c Release.
You can set the deploySubpath value in Settings > Extensions > Azure App Service or by editing the file settings.json in the .vscode directory. This directory will be created in the root directory of your workspace.
Be careful to always set the deploySubpath relatively to your .vscode directory. In my case my workspace looks like this
-- .vscode
:- project_1
`- project_2
where project_1 is my ASP.Net Core project and project_2 is a nodejs project.

Team Services Azure App Service Deploy failure - Virtual Application characters?

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.

Resources