How do you upload a downloadable Azure DevOps marketplace extension? - azure

I cannot work out how to upload this SNYK extension for Azure DevOps that I downloaded from the Marketplace. It did not offer any other options than downloading, and it then showed thwse instructions. However, I do not understand them and cannot seem to impliment them.
I added /_gallery/manage to the URL I found on the first page of settings. That caused a 404 error. Is this not the correct URL?
I went to the manage extensions page that can be accessed from the same top-right of screen shopping bag button as the marketplace and leads to settings, there is no option to upload. I cannot find any instructions for uploading a donwloadable extension and I don't see any options allowing for it. Where can I find the upload button?
Does anyone know what this screenshot is trying to indicate to me to do?

After you install any Extension in Azure DevOps, You can utilize it in your release pipeline and start creating tasks and triggers.
To Install the Snyk Extension, I went to my Azure DevOps organization > Organization Settings > Extensions on left
Clicked on Get it Free this routed me to my Azure DevOps Organization. Make sure you open this in the next tab of the browser as your Azure DevOps login.
Clicked on Proceed to the organization, And the Extension will be added to your Azure DevOps Organization. Now I created one Service Connection with this extension like below:-
You can get the API token from your Snyk account by logging into snyk.io like below:-
To build tasks or triggers with snyk in Azure DevOps, you can visit > Pipelines tab in Azure DevOps organization > click on Edit pipeline and add a Snyk task like below:-
YAML code added as below:-
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
trigger:
- main
pool:
vmImage: ubuntu-latest
variables:
- group: SharedVariables
steps:
- script: |
echo $(databaseserverpassword)
- task: SnykSecurityScan#1
inputs:
serviceConnectionEndpoint: 'sidsnyk'
testType: 'app'
monitorWhen: 'always'
failOnIssues: true
Ran the pipeline like below:-
You can set Fail on issues to false in your yaml pipeline to run the snyk:-
- task: SnykSecurityScan#1
inputs:
serviceConnectionEndpoint: 'sidsnyk'
testType: 'app'
monitorWhen: 'always'
failOnIssues: false
You can also run Snyk tasks directly from Release pipeline like below:-
Reference:-
https://marketplace.visualstudio.com/items?itemName=Snyk.snyk-security-scan
https://snyk.io/blog/building-security-into-your-azure-devops-pipeline/

Related

How to send work items through release pipeline after deployment azure devops

How to send work items through release pipeline after deployment completed in azure devops
I try to use send email task but there is no option
You can link Work Items to your pipeline like below:-
I went to my Release pipeline and Options > Integrations> Report Deployment Status to work and Report Deployment Status to Boards refer below:-
I did one commit in my existing pipeline repo and linked a Work Item to it like below:-
The Pipeline started running after the commit and the task was added to the work item like below:-
Work Item:-
Now, I triggered a release pipeline for the same and checked if the work items are included like below:-
After the release is complete click on 3 dots like below and select Send Email
Now, As this Work item is included in the build, I send it via Email, You can enable Email notifications at the Organizational level and Project Level both.
Project Level > Project > Project settings > Notifications > New subscriptions > Build > A Build completes >
You can also create a notification for Release refer to below:-
I received an Email after the successful build and release with the associate artifact like the one below:-
You can enable this Email Notification at the Organizational level too.
Additionally while running pipelines, You can follow the steps below:-
Reference:-
Configure pipelines to support integration - Azure DevOps | Microsoft Learn

Unable to deploy a .NET core app from DevOps to Azure using publish profile

I am creating a new Azure Pipeline to deploy .NET Core API app to an App Service in Azure. I am using connection type=publish profile in the pipeline, which is asking for a .pubxml file.
I have already committed the .pubxml file in my Azure repository.
But while giving the path for getting this .pubxml file, I am suspecting that I can't get .pubxml file through build artifacts. Is there any way to get the .pubxml file from azure repos to release pipeline?
I tried with $(Build.SourcesDirectory)\${{ parameters.Location }}\Properties\PublishProfiles\fcmapapi_Dev%20-%20Web%20Deploy.pubxml but no luck.
Any suggestions?
Step 1: Add Azure Repos / Build artifact with an alias to your release pipeline.
https://learn.microsoft.com/en-us/azure/devops/pipelines/release/artifacts?view=azure-devops#artifact-sources
https://learn.microsoft.com/en-us/azure/devops/pipelines/release/artifacts?view=azure-devops#artifact-sources---tfvc-git-and-github
Add "Build" resources as an artifact:
Add "Azure Repository" as an artifact:
Once, you have added both, the classic release pipeline will look like this:
Step 2: Use the three dots to browse the files / packages.

Download result of Azure Release Pipeline

I have a release pipeline that combines two build pipelines artifacts to create the full release. I need to be able to download the result of this task after is done.
I run the Archive Task to zip the results but I don't know how to save it somewhere where I can download it using the Azure Pipeline agent.
Is there a task that can trigger that as a download or can I save it as an Artifact?
Thank you
Yeah, what you have to do is publish and then consume artifact in your Release pipeline. Here you have documentation
steps:
- publish: $(System.DefaultWorkingDirectory)/bin/WebApp
artifact: WebApp
Id you use Yaml then you should use this:
steps:
- download: current
artifact: WebApp
If you use Classic releases you needs to confgure it on designer.
Please use this task in your pipeline:
and then configure your release here:
Just realized that if I do this with my On-Prem agent I can get the file form the agent's file structure.
Would be nice though if I could get the file straight from Azure instead.
Thank you.

How to trigger an AzureML Pipeline from Azure DevOps?

If we have an AzureML Pipeline published, how can we trigger it from Azure DevOps without using Python Script Step or Azure CLI Step?
The AzureML Steps supported natively in Azure DevOps include Model_Deployment and Model_Profiling.
Is there any step in Azure DevOps which can be used to directly trigger a published Azure Machine Learning Pipeline while maintaining capabilities like using Service Connections and passing environmental variables, Gated Release (Deployment)?
Edit:
This process can then be used to run as an agentless job.
I am afraid there is no other steps available in Azure Devops which can directly trigger a published azure ml pipeline. You have to use Python Script Step or Azure CLI Step in azure devops pipeline to trigger azure ml pipeline.
To trigger azure ml pipeline using azure cli task in azure devops pipeline. You can check out below steps.
1, Create an azure pipeline. See example here.
2, Create an azure Resource Manager service connection to connect your Azure subscription to Azure devops. See this thread for an example
3, Add Az cli task in your yaml pipeline. Run below scripts as inline scripts. See document here for more information.
steps:
- task: AzureCLI#2
displayName: 'Azure CLI '
inputs:
azureSubscription: 'azure Resource Manager service connection'
scriptType: ps
scriptLocation: inlineScript
inlineScript: |
#To install the Machine Learning CLI extension
az extension add -n azure-cli-ml
az ml run submit-pipeline --pipeline-id "{id}"
Update:
If you want to avoid using build agents. You can run the invoke rest api task in an agentless job. See below steps:
1, Create a Generic service connection in azure devops. See here for creating service connection.
2, Add below url as the Server URL of the generic service connection. See here for more information about below url.
3, Add a agentless job(server job) in your pipeline. Add invoke rest api task in this agentless job. So that, the pipeline will execute the invoke rest api task to trigger the azureml pipeline without using a build agent.
You can also setup an azure logic app in your azure subscription.
You can set the logic app trigger as azure devops events. Or you can set a http request as the trigger events(You can the use invoke rest api task or azure devops web hook to call this http request to trigger this logic app).
And then add a HTTP action with the url as above url screenshot. Please see here for more information.
Assumptions:
An AzureML Pipeline is published and the REST endpoint is ready- To be referred to in this answer as <AML_PIPELINE_REST_URI>. And Published Pipeline ID is also ready- To be referred to in this answer as <AML_PIPELINE_ID>
You have the Azure Machine Learning Extension installed: Azure Machine Learning Extension
To Invoke the Azure Machine Learning Pipeline we use the Invoke ML Pipeline step available in Azure DevOps. It is available when running an Agentless Job.
To trigger it the workflow is as follows:
Create a New Pipeline. Using the Classic Editor, delete the default Agent Job 1 stage.
Add an agentless job:
Add a task to this Agentless Job:
Use AzureML Published Pipeline Task:
Use the Service Connection Mapped to the AML Workspace. You can find more on this at the official documentation
Choose the Pipeline to trigger using the <AML_PIPELINE_ID>:
Give The experiment name and Pipeline Parameters if any:
That's it, you can Save and Queue:
Alternatively, you can simply use the following jobs:
- job: Job_2
displayName: Agentless job
pool: server
steps:
- task: MLPublishedPipelineRestAPITask#0
displayName: Invoke ML pipeline
inputs:
connectedServiceName: <REDACTED-AML-WS-Level-Service_Connection-ID>
PipelineId: <AML_PIPELINE_ID>
ExperimentName: experimentname
PipelineParameters: ''

Azure DevOps VSTest task - appconfig settings

This is a question on how to use a static value for VSTest unit tests run on Azure DevOps Pipeline.
When I develop a unit test that depends on my Web API, I put URL of the Web API hosted on my local dev machine in appsettings.json and this works great. However, when the unit test is run on Azure pipeline, of course it cannot access the Web API hosted on my machine and it fails. I can change the appsettings.json file to point to Web API on Azure but I wish there is a way to always point to the WebAPI on Azure when the unit test is run on the pipeline, overriding the setting in appsettings.json. Is there such a way?
For the Azure pipeline Release, I know I can set variables for app services with Azure App Service Settings task (https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/azure-app-service-settings?view=azure-devops). Not sure similar functionality is available for VSTests.
You can use File Transform task to substitute the variables in appsettings.json file with pipeline variables. See here for more information
So you can add a File Transform task before the build task. Then define a variable(eg. TestData.Url) in your pipeline variables.
See below yaml example.
- task: FileTransform#1
displayName: 'File Transform: '
inputs:
folderPath: '$(system.defaultworkingdirectory)'
enableXmlTransform: false
fileType: json
targetFiles: '**/appsettings.json'
There are other tasks can do the same work. You can check out task Set Json Property, and task Magic Chunks
You can also put the URL of the Web API in the TestRunParameters section of runsettings file or Properties section of testsettings file. And modify your test code to get the URL from testsettings/runsettings files. Then you can use overrideTestrunParameters attribute of Vstest Task to override the URL. See Vstest task document for more information.
You need to have two appsettings files. One for dev (you local test) and the other for production (AzureDevops pipeline).
Like this if you need to make some changes to test locally you change only the dev one.

Resources