How to publish WebApp as Azure Virtual Application from TFS Release (vNext) - powershell

I need to publish 3 webapp to azure using release manager from TFS, and I need all of these 3 apps inside wwwroot subfolder:
wwwroot\app1
wwwroot\app2
wwwroot\app3
This is because I have a azure virtual application pointing to each of this folders.
I have a release for each app. Each app should deploy not to wwwroot, but to a folder inside wwwroot (app1, app2 or app3).
At this moment what I'm doing as a workaround is deploying a package (zip) with the name of the folder that I need (app1, app2 or app3), however, this is just a workaround, because if I activate "clean" in the release task, this clean all wwwroot folders and clean the other apps.
Is there anyway to deploy using some Task to a specific folder instead root folder (wwwroot)? Or, is there a way to deploy to azure virtual application?
If not, is it possible to send me a powershell command to delete a specific folder in the wwwroot?
I'm using "Azure Web App Deployment" task that uses Publish-AzureWebsiteProject PS command, but I don't know if it's possible to send some argument to send this to a specific folder inside wwwroot? Is there some argument to do that?
Thank you all for the availability

You could directly use the AzureRM Web App Deployment task released by Microsoft which allows for virtual directories.
Update
It's a build-in task called Azure APP Service Deploy
The task you are using-- Azure Web App Deployment is deprecated.
NOTE: This task has been deprecated. To update Azure App Services using Web Deploy or Kudu REST APIs, use the Azure App Service
Deploy task.
We recommend you replace the Azure Web App Deployment task with the
Azure App Service Deploy task in all your build or release
definitions.

I found another solution. Using cURL to upload by FTP and I can control each individual folder.
Anyway, if someone knows how to deploy directly to a virtual app directory, please provide answer :)
Thank you

Related

Copy or Rename file in sub folder under Web App through azure release pipeline after web deploy

I have an Azure DevOps release pipeline, deploying my code using Web Deploy to Azure Web app to different environments (Dev/ SIT/ UAT/ PROD). Now, I need to include a task to copy/ rename one Configuration file (environment specific), which is inside 'Config' folder, to another file inside the same folder. Please note, the config file is not under the root folder of the web app.
Is there a way to accomplish this using 'post deployment action' or command line script task? I couldn't understand how can I refer the source folder of the web app for the copy operation. I was referring the following page but couldn't find one that will help me to achieve the task. Any help is appreciated.
https://learn.microsoft.com/en-us/azure/devops/pipelines/release/variables?view=azure-devops&tabs=batch
The Post deploy action script is running on azure (through Kudu API): Command
So, if the file is existing on the azure web app, you could copy it through Post deploy action script, for example, Site.css is in wwwroot\Content folder after deploying, then the script could be like this:
Copy Content\site.css Content\site1.css /a
Otherwise, you could store the necessary data in App settings or Configurations of Azure Web app.

Angular application from Azure Pipeline into App Service Directory

We have an Angular 7 application on one git repository and an ASP.NET Core 2.2 Web API on another git repository. We use Azure pipelines to deploy both repos into an Azure App Service.
I have successfully been able to configure the Web API to deploy to the root directory and the Angular client into a wwwrooot sub directory.
However, in order to achieve this I need to configure the wwwroot sub-directory as an application, which makes the application fail with HTTP 404. Once I change the settings to be "Directory" in the Azure app service, everything works as normal.
Is there a way to have the Angular pipeline deploy to the sub-directory while configured as Directory instead of Application?
Thank you,
I solved my issue from within the pipelines. Following this post (VSTS build with multiple repos) I added the FE artifacts to the pipeline and simply copy it's dist contents to the wwwroot folder of the API build folder. Then I simply deploy everything to App Services and now both the API and Angular App are deployed on the same server and working.
Hope this helps someone.

VSTS - MVC Web app deploy task is deprecated. How to deploy to test server on prem

Setting up a Release definition task to deploy a MVC web app to a test server (on prem). Typically I have done this a FileSystem publish via a Visual Studio publish profile. What task can I use in VSTS to achieve the same thing, assuming I already have a working agent setup on the test server and a successful build?
The app is actually setup as a website on the test server, not a virtual app under another website. Looking at adding the "IIS Web App Deploy" task, VSTS reports that this task is "deprecated, so what is the suggested replacement for this?
I suppose I could use the Windows file copy task, but the build artifacts are zipped. What would I need to use if I went this route?
You can use Visual Studio Build task with /p:SkipInvalidConfigurations=true /p:DeployOnBuild=true /p:WebPublishMethod=FileSystem /p:publishUrl="$(build.artifactstagingdirectory)\\" /p:DeployDefaultTarget=WebPublish MSBuild Arguments to publish web app to artifact folder (e.g. {agent working folder}/1/a).
You also can specify the publish profile directly /p:SkipInvalidConfigurations=true /p:DeployOnBuild=true /p:PublishProfile="{publish profile name}";publishUrl="$(build.artifactstagingdirectory)"
With FileSystem publish method, the published files are in a folder, not zipped, but you can zipped the folder through Archive files task.
Also you can extract files through Extract files task, so you can copy extracted files through Window machine file copy task to the corresponding web site path.
On the other hand, you can deploy the web app through WinRM-IIS Web App Deployment task.

VSTS: Release Management Deploying Artifacts to IIS on Premise

I am using VSTS Release management to deploy artifacts to IIS websites. I have several Web applications and web services to be deployed. So, i am trying to figure out what sort of tasks that best fits my situation.
I have created a build definition with Visual Studio Build Task for projects as this one:
which works fine but i need to add a task for copying the artifacts Under IIS Website Directory.
The other approach is to use IIS web deployment as a task in Release definition, so I created the build definition as:
However, it expects a Publish Profile (the build fails because it can't find it). I don't need to create a publish profile for each project in the application because this would be too much work.
Is there is a workaround for that or what is preferred approach for this?
You can update your build definition to generate a web deployment package and upload it to artifacts. And then in Release Management, add a task to run "projectname.deploy.cmd" in the deployment package to deploy it to your IIS server. Refer to this link for details: How to: Install a Deployment Package Using the deploy.cmd File Created by Visual Studio.
And you can also enable FTP Publishing on your IIS server and add a task in your release to publish the artifacts via FTP. You may need this task:
FTP Uploader.
My Continuous Delivery with TFS / VSTS – Server Configuration and Application Deployment with Release Management blog post (with reference to some previous posts) has all the details you need for deploying your artefacts to target nodes using Windows Machine File Copy tasks then use PowerShell on Target Machines tasks to get them in to correct locations and to do token replacement and anything else that's required.
I would recommend using PowerShell DSC so that IIS is properly configured before deployment but that's not required. Where possible for web apps I favour keeping things very simple by creating artefacts that contain all the web files that are needed for a particular folder and then just using plain xcopy for the deployment.
If you need more control you can also use my MSDeploy VSTS extension to deploy a MSDeploy package
https://marketplace.visualstudio.com/items?itemName=rschiefer.MSDeployAllTheThings
https://dotnetcatch.com/2016/04/20/msdeployallthethings-vststfs-extension-is-public/

Deploying Azure WebJob using powershell automation

I'm trying to deploy an Azure WebJob using the Azure PowerShell SDK or Rest API and I'm having troubles finding support for deploying WebJobs. It's super simple to do through the UI in VS or Azure Management Portal but there doesn't seem to be much automation support.
According to some sites, when you deploy an Azure Website with an associated web job, it's supposed to deploy the Web Job automatically but I'm not seeing that happen when I publish the web project in VS and I don't see how that would work after the bits are compiled through TFS.
I've found some great resources that I've tried following but don't seem to be working for me:
http://azure.microsoft.com/en-us/documentation/articles/websites-dotnet-deploy-webjobs/#deploy
http://azure.microsoft.com/blog/2014/08/18/enabling-command-line-or-continuous-delivery-of-azure-webjobs/
Unfortunately, I need to integrate this automation into a standalone deployment orchestration so I can't tie it to MSBuild.
I'd be happy with deploying both the Azure Website and the WebJob together if that's possible. I would imagine there must be a way to automate the uploading of a zip file containing the WebJob executable to the website like you can through the portal but I haven't had any luck finding it.
Apparently according to this post the job just gets put in a folder matching the job name in your websites App_Data folder.
You might have to manually upload the job as a zip file once, but afterwards I assumed you could do some magic in your deployment or in a post build task to build the web job console app and stick it in the appropriate App_Data folder.