Deploying Azure WebJob using powershell automation - powershell

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.

Related

Install or use software on Azure Devops Hosted Agent

I am new to Azure Devops and hoping this is a simple fix. I have a powershell script that uses Tabular Editor to deploy .bim file to Azure Analyses Services. This works great on my local machine. I have tried to get this working in the devops pipelines with no luck. I haven't found away to install the software on the hosted agent - Question 1) can I install software on a Hosted Agent e.g. on Hosted VS2017.
Failing being able to install software on Microsoft's hosted agent. I checked in the TabularEditor.exe file into the source code (I know this ins't best practise). The executable file gets put into the build artifact and publishes. Then in the release when my powershell script is called it just hangs, the script gets stuck here. The powershell script reads from a config file and also uses the path to the tabulareditor executable.
The script I am using works fine if you use a self hosted machine assuming the agent has the correct permissions.
I have another Analyses Services script that is ready and works provided Someone creates an XMLA of the model first, then we provide that as an input instead of a .bim file. But this is not quite the automated route I am looking for.
Also I am aware that there is a third party task that does azure analyses services deployment but I want to avoid using that.
In summary I am looking to find out
1) if I can indeed install software on Microsofts Hosted Agent
2) Should I be able to use the executable in my build artifact instead
3) Is there a better way to deploy Analyses services with a .bim file
I appreciate this is long winded and slightly unique but any insight or information would be appreciated.
Thanks

Deploy website on iis using VSTS

I want to deploy multiple websites on IIS using a single task in VSTS.
How to achieve this? Using a release definition i included a task which deploys the website on IIS. But in this arrangement,i need to create as many tasks,as many websites are there. what are the ways in which i can use either a JSON file or something and create a single task which reads the website names and port numbers etc from the Json and deploys all websites in one go.
There isn’t the official task that can deploy web apps together, you can create the build task through VSTS extension: Add a build task.
You can refer to the source code of IIS Web App Deployment Using WinRM extension to build a task extension.

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

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

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/

OnPrem TFS 2015.1 vNext - What step to Release to on premises IIS server?

I'm trying to use TFS 2015.1 on premise to build a CI pipeline for our dev & uat. I've created a vNext CI build, which builds fine. But when I want to add a deploy step for on prem IIS server, I only then see Azure Web Deployment options.
Ideally I wanted to add a step which uses the existing deploy (MS Deploy) profiles, which I'm able to use from VS2015 directly, using 'Publish'. However I see no option to do so.
How can I deploy the latest build to internal dev servers (not Azure)? I would like to use the MS Deploy option, unless there's a better way of doing it?
The fact that their is no option to starts to make me think there's probably a different way to accomplish it!
Thanks.
If you're able to upgrade to TFS 2015.2, web-based Release Management came out with it that works similarly to Build vNext with flexible and open-source tasks. You can also customize tasks.
Here's a link for IIS Web App Deployment from the vso-agent-task's GitHub repo where Microsoft stores updated versions of their tasks that you can download for web-based Build and Release Management.
I'll be publishing a blog about web-based RM with TFS 2015 Update 2 or VSTS on my website in the next few weeks. To give you an idea though, the starting point (for a web application) is a folder in your web project called WebDeploy (no significance - any name will do) that contains a PowerShell DSC script that configures the server, deploys the web files and then replaces any tokenised configs. To give you an idea see this post about how to use DSC to configure servers. (Only covers part of the final script though!) The next steps are:
In the build hub create a Website artifact - containing your web files and DSC script.
In the release hub for an environment use a Windows Machine File Copy task to deploy the artifact to a temp folder on the target node.
Then use a PowerShell on Target Machines task to execute the DSC script. After configuring the server the script copies the web files to their proper location, sorts out config using xReleaseManagement and cleans up the WebDeploy folder.
See this article for general details of the route I'm taking, but watch out as it has some errors eg the firewall instructions are incomplete (file and print sharing through the firewall needs to be enabled).
I can thoroughly recommend the PowerShell DSC route - I've had a few glitches but on the whole it feels very productive and the right way to be going.