Deploy Release in Azure Devops from a logic app - azure

We have created a pipeline to restart multiple VM services in correct order. Within Azure Logic App I can create a release, but want to deploy the same release daily. How can I do this in Logic Apps?
I current use logic apps to shutdown and start VMs daily as they are not used during silent hours but need to deploy restart services pipeline regularly.
From the picture you can see it only creates release not deploys it. I need it to only deploy to CL04 stage daily not all three stages and really don't need a new release every day, just redeploy release 7 to the same environment that the start VM logic app is running on daily.

but want to deploy the same release daily.
You can achieve this if you use Recurrence Trigger in your Logic app workflow.
For complete information you can go through this document.

Related

Update the image of azure container instance?

Azure Container instances
This is the first time i use docker image
when i trying build and upload new version code and push in Azure Container registries
but if i want to apply new version code , i must restart Container instances by manual to apply new version code , it annoys me and is a waste of time
How to resolove auto restart or redeploy when i push new version code in Container registries in Azure ?
this is log deploy azure of myself
I can think of a couple of ways to do this.
AKR Webhooks
I probably will approach this by looking at the webhooks in AKR.
Then, create a Logic App to receive the webhook call when a new image is pushed. References.
In the Logic App, you can call one of the Azure Container Instance APIs to restart the container group.
You will need to consider the security of the Logic App, which can only be called by your AKR's webhook.
CI/CD Pipelines
Assume that you have used a CI/CD platform like Azure DevOps, where you can create build pipelines.
The pipeline can build and push the images to your AKR, then create a step to run Az command to update the instance group.
I probably prefer the pipeline approach as I can see the history of what images have been released on the DevOps page.

How to create app services for feature branches dynamically in Azure DevOps

I'm working on an API in core3.1. We have a build pipeline that builds and unit tests any change for any branch. And release pipelines for development and master branches. These deploy to designated app services in Azure.
Now we would like a release pipeline for feature branches. So what we want is a pipeline that can dynamically created app-services per feature branch and deploy to that app service. And preferably dynamically delete the app-service when the branch is deleted.
Just to clarify, the proces how we would like it:
a developer creates feature branch and pushes it >
the build pipeline builds it >
an app service gets created automatically >
stuff gets deployed to that app service >
developers work on the branch and changes get build and deployed to the app service like normal >
at some later point a developer deletes branch >
app service gets deleted automaticcaly
Is there any way to accomplish this? Maybe there is a standard way?
Feature branches are located in a subfolder, e.g. "feat/feature-branch-name".
I'm fairly new to Azure and DevOps.
Any help is appriciated. Thanks in advance.
You should follow the practice of Infrastructure as Code (IaC) and use ARM templates in your pipeline to create/update/delete your Azure resources. You can also use the built-in tasks available in Azure DevOps to deploy your ARM templates.

Creating dev/Staging enviroment in Azure

I am trying to create a deployment plan for my web application in Azure which can support 2 environments (Dev/Staging). Basically, I want the code checked in by developers to be deployed to the Dev machine end of the day. And then the latest Dev changes to be merged with staging branch and if no merge conflict happened a new publish goes to staging machine. Can anyone help me where to start and what feature in azure i can use to server this?
You could use Azure Devops to trigger scheduled builds (at the end of the day) to perform the routine you are describing. you could also use releases and trigger them automatically from the builds that happen on a schedule.
You would also need to deploy vsts agents on the machines or allow for vsts agents to somehow talk to the machines to upload code to them

Automatically start/stop Existing Azure VM as build agent in VSTS

I'm able to register my existing Azure VM as build agent in VSTS. Build works fine but I would like to turn the machine on and off only if there is any work for it. Is there any way how I can turn on the VM if I see there is some work for it in a queue and then turn it off if the queue is idle for let's say 5 minutes?
Add a hosted agent job to the start to start the VM and add an agent job or additional step to the end to shut down the VM when finished.
Add an Agent job to run this as hosted to start the VM. Then use all build steps as self-hosted(private).
Add your Azure subscription
Choose Inline Script to add the following to start it with VM name and resource group
start-AzureRmVM -Name ""-ResourceGroupName ""
Add another Agent Job or additional step as the last Step
To shut down the VM when the build has finished.
With the following Script
stop-AzureRmVM -Name ""-ResourceGroupName "" -Force
I'm wondering if this could be helpful for you because this is not exactly what you asked for. I used REST API calls before the build and after the build to start and then stop a specific VM. See how to start and power off a VM in the API documentation.
I created an agentless job as the first step, with a task entitled Invoke REST API. The task lets you authenticate to your Azure account, so you don't have to handle that manually. All you have to do is specify the URL suffix. For instance, to start a VM named MyVm, you add a suffix similar to the following one:
/subscriptions/subscription-id/resourceGroups/resource-group-name/providers/Microsoft.Compute/virtualMachines/MyVm/start?api-version=2018-06-01
where the subscription ID and resource group can be verified in the Overview page of your virtual machine in Azure.
After the build you can add another agentless job, but this time with a REST call of the powerOff endpoint:
/subscriptions/subscription-id/resourceGroups/resource-group-name/providers/Microsoft.Compute/virtualMachines/MyVm/powerOff?api-version=2018-06-01
There isn’t the good way to start/stop azure VM when build in VSTS. Regarding WebHook, there isn’t the event for queue build, for other events, they aren’t meet many requirements (e.g. non-CI build, queue build manually)
I recommend you use Hosted agent, with free Hosted Pipeline, you get 4 hours (240 minutes) per month and maximum duration of 30 minutes per build or deployment in Team Services.
How to buy more pipeline capacity for builds and releases in Visual Studio Team Services
Workaround:
Queue build at the specify time, for example, 7:00 am on Monday and Thursday, then you can auto-start and auto-shutdown the VM
Run on Hosted agent (Execute Powershell to start VM)=> Run on private agent
More information, you can refer to: How to Create a Monster Build Agent in Azure for Cheap
You could try using a WebHook in VSTS, and select the most appropriate event (like code pushed, or release created). Open the admin page for the team project in Visual Studio Team Services, and on the Service Hooks tab, run the subscription wizard, select the event you're interested in, and fill in the relevant criteria.
You could then use an Azure Automation Runbook to subscribe to the WebHook and, using PowerShell, either use the build VM if it's already started or else start it up. You could use another WebHook to signal that a build has been completed, or poll VSTS from the VM via its various APIs.
You might want to delay shutting the VM down after a build, as there is a time cost associated with starting up / shutting down.

How to deploy a webjob through CI in VSO with vNext

I'm trying to deploy a scheduled webjob through CI and vNext tasks in VSO.
I followed the steps in the following tutorial to deploy a webjob along with a web app ("Enable automatic deployment with a web project"):
https://azure.microsoft.com/en-us/documentation/articles/websites-dotnet-deploy-webjobs/
I succeeded partially: the webjob gets deployed along with the web application. However, it is marked as On Demand instead of Scheduled (or whatever the proper status is). I can run the webjob manually and it runs just fine. I checked the files webjob-publish-settings.json (in the webjob) and webjobs-list.json (in the web app) and they seem to be alright, judging from the tutorial.
Am I missing anything? Thank you.
You can use the cron expression to create the webjob scheduler if your app is running in Basic or High mode. Refer to this link for details: Create a scheduled WebJob using a CRON expression
Otherwise, you need to enable continues delivery of Azure Webjobs.
More reference: Deploy your WebJobs projects with your Azure website using continuous delivery

Resources