How should I trigger ARM deployments - powershell

We are trying to establish a continuous deployment environment. Conflicted how to do ARM deployments. Deploying all the resources as a group is much better them handling them individually.
ARM has a nice declarative syntax. We are telling what we intend to create" without having to write the sequence of programming commands to create it. Which is great but how should we run them ?
Two options come up to my mind
I.I could download the templates and use power shell.
II. Trigger using Azure automation
III. x
What is the best practice ?
Reference
Octopus integration from source code

If you're doing this as part of your CI/CD chain, you probably want to check in the templates and deployment scripts with your source code. That way, the definition of the infrastructure is kept with the code that's intended to run on it.
If this is part of some other workflow, it really depends on the workflow :)

I would suggest using powershell\cli and just invoke the template from the uri, that is the easiest way of doing that (instead of downloading it). This can be run with anything that is capable of running a custom script task, or specific CI\CD systems that have steps to deploy ARM Template (VSTS\Octopus\probably something else)
I would advice against Azure Automation for that cause.
Also, I do suggest separate code from arm templates

Related

on Azure in repo's script of CI/CD for the best practices which code to use?

on Azure in repo's script of CI/CD for the best practices which code to use: JSON or PowerShell or CLI ?
which code from above is the best and professional way to use ?
Thank you.
As for the best practices of script of CI/CD, each of them has their own features and could be used in it.
For example, when you would like to create the script to build VMs, you could select the JSON one because through the JSON script, you could see all information of the VMs more directly than other kinds of scripts. You could see the example through https://learn.microsoft.com/en-us/azure/virtual-machines/linux/tutorial-build-deploy-azure-pipelines?tabs=java-script .
As for building AKS, you could use Power shell to create the script as it needs fewer related properties to be defined while comparing with other scripts. You could see some examples in the following document https://learn.microsoft.com/en-us/azure/aks/kubernetes-walkthrough-powershell
To be concluded, each kind of way to create the script is available for CI/CD and you could select which you are used to using or according to the advantages of each script.

Visual Studio Online / Azure stopping and starting web applications using Powershell

I'm using Visual Studio Online's build tools to deploy web applications from a single solution. I've occasionally been running into file locking issues.
Error: Web Deploy cannot modify the file 'Microsoft.CodeAnalysis.CSharp.dll' on the destination because it is locked by an external process.
After some Googling, I believe the "fix" is to stop the web applications before deployment on Azure and start it back up after. Sounds legit.
However, there does not seem to be a straight forward way to do this directly on VSO's build definitions. I've created an "Azure Powershell" build task, but it wants a PS1 file from the repository. It doesn't seem to let me just run Azure Powershell commands (e.g. Stop-AzureWebsite) from here. My team has created a work-around where we have a "run.ps1" that just executes the command you pass as a parameter, but none of us are satisfied by that.
What are we missing? There has got to be an easier way to do this without having a PS1 script checked into source control.
I solved this by installing Azure App Services - Start and Stop extension from Visual Studio Marketplace.
When installed, it will allow you to wrap the Deploy Website to Azure task in your Release definition with Azure AppServices Stop and Azure AppServices Start tasks, effectively eliminating the lock issues.
Check if you are using "/" on the "Web Deploy Package" path for folder separators instead of "\".
i.e. change
$(System.DefaultWorkingDirectory)/My Project/drop/MyFolder/MyFile.zip
for
$(System.DefaultWorkingDirectory)\My Project\drop\MyFolder\MyFile.zip
I noticed that was the only difference between the one I was getting the error and the others (the Restart step I added was not helping). Once I modified the path, I got it working.
Sounds crappy, but fixed my issue.
Did you use the Build Deployment Template that sets the correct msbuild parameters for you for your package? You can see how here. I would create a build using that template and see if you have the same issues. If so ping me on Twitter #DonovanBrown and I will see if I can figure what is going on.
As a rule it is good practice to have any scripts or commands required to deploy your software to be checked into source control as part of your build. They can then be easily run repeatedly with little configuration at the build level. This provides consistency and transparency.
Even better is to have deployment scripts output as part of the build and use a Release Management tool to control the actual deployment.
Regardless having configuration as code is a mantra that all Dev and Ops teams should live by.

How to use Jenkins Multi-Configuration (Matrix) type Projects?

Jenkins official Wiki page for Matrix projects isn't really helping me; so I have a few questions.
We're trying to build a couple of projects that are all essentially the same, just some are being branded differently for our customers. In other words, the software / tests / etc. are all identical, except for some tweaks to turn BrandA into BrandB (or BrandC, etc.)
I figure I should be using a Matrix project to create builds for BrandA, BrandB, etc. While I haven't figured out all my steps yet (including how to rename executables after they're built) I know that I will need to pass the Brand Name to many of my Jenkins Powershell scripts during the build process, and then use that brand n the script.
How do I get these variables into my scripts? Are they automatically passed in to every build step in Jenkins? What is the variable name to use?
Finally, is there a good resource on building these multi-configuration projects in Jenkins? I can't seem to find anything comprehensive online.
If you usually build the job for BrandA and only occasionally for BrandB and BrandC a matrix project may not be what you want. I recommend, instead, using a parameterized job where the brand is a parameter whose default value is BrandA. If the parameter is named BRAND the parameter is accessible in all of the builds and publish steps with ${BRAND} and as an environment variable as %BRAND%.
I refer you to the parameterized build wiki for more details.
Yes, ${BRAND} and %BRAND% should work fine.
If you're using Maven, ${env.BRAND} does this too.
There's a plugin that you can see all Environment Variables that are available to your job/build.
https://wiki.jenkins-ci.org/display/JENKINS/EnvInject+Plugin
I'm not aware of that kind of process but I suggest you tu use the Copy project functionnality.
New Job
Copy From existing job
You will have a copy of your Job and you'll be able to setup easily all specific fields.

One click deployment using scripts

I want to deploy a web solution for local server using one click deployment using powershell or any other scripts.
Can any one share any ideas
Powershell can be use in conjunction with Psake which is a DSL that allows you to script up deployments (or basically anything really) with a dependency chain. It also abstracts MSDeploy to some extent, making it easier to roll out installs to IIS. Note that MSDeploy can also be used completely independently for relatively simple deployments (such as web sites without any reliance on messaging queues, databases, supporting services, etc.)
Other automated approaches include the likes of Octopus Deploy which works by having a central management node push out installations to 'agents' installed on target machines.
Both approaches require you to write your app in a reasonably deployable manner (e.g. having suitably transformable configurations files)
Does that help? There are a number of other options out there but these should help to point you in the right direction.
Also check http://psappdeploytoolkit.codeplex.com/ (seems to be what you want)
and maybe https://github.com/mislav/git-deploy or https://github.com/p-blomberg/Web-app-deploy-script
Try this approach... this is not the compete but will help you in moving one click direction..
http://ravisoftltd.wordpress.com/2014/04/08/one-click-deployment-with-sharepoint/
If you are trying to deploy from MSBUILD-files (so something like asp or MVC), I would like to point you to Package-Web.
It still has some minor flaws (which can be worked around pretty easily), but works pretty good.
Only downside that I know of: you have to prepare your project by installing a nuget-package (or get those files into your build process some other way)
You can do it using a powershell script with something like
[string] $package = "solution.wsp"
stsadm -o addsolution -filename $package
stsadm -o deploysolution -name $package -immediate -allowGacDeployment

Automate deployment of XMLA / documentation on Microsoft.AnalysisServices.Xmla

I'm looking to automate the deployment of XMLA scripts. I've come across an article that gives a small demo, but I'm hoping to find more info.
Specifically, where is the documentation for Microsoft.AnalysisServices.Xmla.XmlaClient and what is the best approach for overridding the database and connection values that are embedded in the XMLA script?
I assume you are just trying to deploy the analysis service cube. This utility has commandline switches and can suport configuration for different targets
Analysis Services Deployment Wizard
If you need to add further customizations, you can always process the resulting xml files with either xslt, powershell, or .net
ascmd.exe can also run xmla scripts:
ascmd.exe commandlline utility
Apparently Microsoft.AnalysisServices.Xmla.XmlaClient is an undocumented library that is actually part of Management Studio and is not re-distributable. I think that using one of Jason's suggestions or the AMO library are your only approaches.