Script error while using deploy.ps1 to deploy virtocommerce project - powershell

I'm using the official virtocommerce azure deploy script under folder "virtocommerce\src\Extensions\Setup\VirtoCommerce.PowerShell" to deploy virtocommerce(with azure tool v2.4), i encounted some problems while running "deploy.ps1" script in windows azure powershell
In "azure-db.ps1", there's lot of syntax like "Get-Date –f" , the dash character is wrong ,"–" must be "-", otherwise you will get error.
In "azure-deploy.ps1", there's a function "build-search" which use cspack.exe to create "ElasticSearch.cspkg",that's correct, but for other packages such as "CommerceSite.cspkg" and "AzureScheduler.cspkg", i did not found any functions to create those packages, this will lead to an error says "CommerceSite.cspkg" can not be found.
Does anybody has the same problems?

Turn out that there's some problem inside code:
"deploy.ps1" script is using deploy-tfs.ps1 , and use parameter "$build".
parameter "$build" has been reset to 'False' in "deploy-tfs.ps1"
"azure-deploy.ps1" using "$build" to decide if it's need to build the azure package, and this parameter is always 'False', so the azure package will never be creat.

The script is designed to run on azure sdk 2.4, not 2.5. The script is used to deploy daily both demo and testing environments and were completed succesfully today. You can see the status here: https://virtocommerce.codeplex.com.
As for cspkg, it is generated during actual build, by msbuild. The elastic search ccspkg has to be created differently, as it has to include javaruntime in addition to elasticsearch runtime and packaged into a single setup.
The new, 1.13 version of Virto Commerce by default deploys azure website instead of azure cloud service for website and scheduler (deployed as a web job). Only elastic search is deployed as a cloud service. The setting can be changed in deploy.ps1.
Also make sure to check the complete instructions on how to deploy source code to azure at http://docs.virtocommerce.com/display/vc1devguide/Source+Code+Azure+Deployment.

Related

Why my Azure functions are not visible in the function list after my deployment from GitHub/Kudu?

I'm trying to deploy my first HTTP trigger Function App to Azure.
It was created with the Azure Function extension in VS Code with TypeScript template.
I use my GitRepo as a source and the Kudu build App Service.
My functions are working well locally. I can see them in VS Code > Azure tab, Local Project > Functions.
I have no error on the deployment itself but I cannot see my two functions in the Azure Functions list.
In the kudu UI, I see that all my files are correctly deployed :
Kudu screenshoot
My settings are :
settings
Where can I find some logs on what went wrong? Any idea of other things to check?
Any help will be appreciated.
I could use Zip deploy (https://learn.microsoft.com/en-us/azure/azure-functions/deployment-zip-push) as an alternative way to deploy this (I haven't tried it yet). I would like to know what's wrong with my current setup.
Not sure if the problem is that you configure the wrong runtime.
Here is the steps I did:
Create a Function app project with an http-trigger function based on TypeScript in VS Code:
Upload the project to GitHub.
Using deployment center to configure deploy from Git on portal.
After deploy, check in Functions page:
By the way, you could deploy from VS Code directly:

How to get latest version of Microsoft.TeamFoundation.DistributedTask.Task.Deployment.dll?

Where can I download the latest version of Microsoft.TeamFoundation.DistributedTask.Task.Deployment.dll for a release on Azure DevOps?
Microsoft-hosted agents are regularly updated to make sure the latest and applicable images of the softwares are applied to the agents.
If you want to use the latest version of softwares to run the related pipeline tasks on DevOps,you can install the latest softwares on the agents which you used .
If the agent you used is privated agent, you need to manually install or upgrade all the softwares you request on the agent machine.By downloading the latest package from Internet or using the related commands to install/upgrade the softwares.
You can refer to this case for details.
For other SO users could get clearly know more details about this issue when they are checking to this ticket, I add the following ticket which relevant with this ticket:
SO forum: Register-Environment Failing
DC forum: Where to download latest versions of deployment utilities for azure pipeline tasks?
When you using the task(such as AzureFileCopy V1.*) which need/import the Microsoft.TeamFoundation.DistributedTask.Task.Deployment.dll file, no matter whether the agent you used is hosted agent or private agent, its version are always be the latest version to the task, because these dll files are all exists depend with task.
According to the content you shared in the DC forum ticket:
I suspect that there's a newer version of these with a newer version
of Register-Environment, because with my version of this PowerShell
module, the following line fails claiming that I'm missing parameters,
specifically a "taskContext."
the error you are facing caused by the configuration of the Microsoft.TeamFoundation.DistributedTask.Task.Deployment.dll file. We did not defined the parameter taskContext in it.
To check and verify it, you can execute the PowerShellOnTargetMachines v2.* task in your private agent, then find the dll file in the path of ~\_work\_tasks\PowerShellOnTargetMachines_3b5693d4-5777-4fee-862a-bd2b7a374c68\2.0.7\DeploymentUtilities. And also, you can see its version is 16.0.0.0.
Then you can use decompile tool, here what I am using is Reflector, to decompile this dll file.
You can see that in the script block of RegisterEnvironmentCmdlet, there does not have parameter taskContext defined in it.
When you use PowerShellOnTargetMachines v2.* task, the parameter for Register-Environment supported only include EnvironmentName, EnvironmentSpecification, UserName, Password, WinRmProtocol, TestCertificate, ResourceFilter, ProjectName, TagsList.
For the parameter taskContext, it is the one which only used in v1.*(See v1.* source code) and does not supported in v2.*. In v1.*, taskContext used for Get-VssConnection cmdlet which dose not used any more in v2.*. That's why you facing the error message in PowerShellOnTargetMachines v2.* task.

How to get Roslyn Analizer results in VSTS Build Definition?

I'm working on DevSecOps. Related to that, I want to secure my application with the help of Roslyn Analyzer. For that I created an MVC Web Application along with custom ruleset in Visual Studio and it's working fine with outputs clearly.
But, when I tried to do same thing with the help of VSTS Build task in my Build Definition in VSTS account. By referring the link, I known that with the help of MSBuild task we can get the Roslyn Analyser results by default. But I didn’t get the results of Roslyn Analyzer results after running my Build Definition. Can you suggest me to “How to overcome this situation”?
If that works locally when run msbuild in command line, then you can try below items to narrow down the issue:
Add a command line task to run the msbuild command line script
directly.
Change another hosted agent.
Deploy an private agent on your dev machine, then check if that works
with the private agent.
You can also reference below articles to troubleshoot the issue:
Using, configuring and distributing Roslyn analysers in teams
Running Code Analyzers on Build Server

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.

Get Build Version in automated build deployment using TFS

I am deploying web application to azure using TFS CI automated build deployment.
In our config maintain build version like 2014.05.19.1 which is $(Date).$(rev) format.
All I want to update config each time build is deployed.For that I am passing value to 'BuildVersion' parameter in template to powershell script which actually performs publishing to azure.
I tried using $(Date:yyyyMMdd)$(Rev:.r) but it is considered string as it is.
I want to get current build version just like IBuildDetail.BuildNumber
within template.
My question is how to get the build version?
If you are using Invoke Process, instead of passing value for BuildVersion parameter you can directly use 'BuildDetail.BuildNumber' in parameters for process like
String.Format("-BuildNumber ""{0}""",BuildDetail.BuildNumber)
This would give the required build number.
If your PowerShell script is being executed from your TFS build, it should have access to the environment variables specific to the TFS context of the build. If that is the case, you actually don't need to pass the $(BuildVersion) parameter to the script, as it already is accessible to the PS script in the $env:TF_BUILD_BUILDNUMBER environment variable. Try testing something like $env:TF_BUILD_BUILDNUMBER | Out-File "D:\Dev\BuildNumber.txt" in your script. You should hopefully see the file containing your build number after running your build.
(I am assuming you are using a relatively new build process template...one that contains the "Post-Build script path" parameter, such as TfvcTemplate.12.xaml)
Hope this is helpful.
I would recommend that you use the right tool for the right job. The build system, is really only for building (compile & test). We have been using it for other things for years coz we did not have another integrated solution. However Microsoft recently bought InRelease and rebranded as Release Management for Visual Studio 2013. I have successfully integrated this with TFS 2012 as well.