I would like to automatically create a service connection in azure devops. Ideally either with terraform or azure cli. I would like to do this as part of an azure devops pipeline using 1 of the above methods. Is this possible? If so how? ... I did not see any docs talking about this but it seems like you should be able to do it instead of using the UI. Thanks in advance.
You can automatically create a service connection using the az cli and the az devops service-endpoint command. Use an Azure CLI task to use this in an Azure DevOps pipeline.
Alternatively, in Terraform, you can use azuredevops_serviceendpoint_azurerm
Related
I want to create azure VM using DevOps pipelines. can you help me out which process/task should I use? And what are the pre-requirements?
I tried with Arm template deployment, azure deployment but not worked yet.
A good approach is using Azure CLI task in your build pipeline.
Here is a sample:
Check the VM in Azure Portal:
Refer to this official doc: https://learn.microsoft.com/en-us/azure/virtual-machines/windows/quick-create-cli
We are using Azure devops to deploy changes to Azure SQL database using dacpac. I want to add a step in the build or release pipeline to take backup of the database but didn't find any task in devops marketplace. Can anyone suggest some way to take db backup in devops pipeline. It will be very helpful. Thanks.
Azure CLI with az sql db commands can be used to manage your Azure Database.
Azure Devops Service provides Azure CLI task to call Azure CLI in Azure Devops pipelins.
And here're two documents that you can refer to:
Use CLI to backup an Azure SQL single database to an Azure storage container
Use CLI to restore a single database in Azure SQL Database to an earlier point in time
I need to create Azure Service Connection, I can create the same using UI in Azure DevOps portal. But I need to know if I can create the same using some Az command or ARM Template or any Powershell script ?
Did you take a look at https://learn.microsoft.com/en-us/rest/api/azure/devops/serviceendpoint/endpoints/create?view=azure-devops-rest-6.0 ?
Here, You can manage Azure services using Azure REST API.
You can create service endpoint via REST API or Azure DevOps CLI.
REST API:
POST https://dev.azure.com/{organization}/{project}/_apis/serviceendpoint/endpoints?api-version=5.1-preview.2
Azure DevOps CLI:
az devops service-endpoint create
I have a timer triggered function that I'm looking to deploy in two different regions in an active-passive pattern. In disaster recovery scenario, I want to disable the active instance, then activate the passive instance in such a way that I can also keep record of this activity.
I know this can be done via powershell/Azure CLI, but I think doing this via Azure release pipelines should be better for auditing purposes. Does anyone know if this is doable?
I donot know much about Azure funtions. But there are azure powershell task and azure CLI task that you can use to run the scripts in azure release pipeline, Since it can be done via powershell/Azure CLI.
In order to run the powershell/Azure CLI scripts in azure release pipeline. You need first connect your azure devops to your Microsoft Azure subscription via service connection. Check here to create a service connection in azure devops. This service connection is needed for azureSubscription parameter of azure powershell task/azure cli task
Then you can create a release pipeline and add azure powershell task or azure cli task to run the scripts.
I need suggestions on how to use azure function app to run "az graph query" in Azure under a resource group and then store the output into storage or keyvault secrets.
Thanks in advance.
Executing a CLI command is not supported by Azure function as of now. You can have a look at supported languages.Instead you can use Azure automation if you are looking to automate Azure operations, have you looked at Azure Automation
You cannot execute Azure CLI commands in Azure Functions but Azure functions support Powershell Core. So you can use Search-AzGraph command to get the required data and store it in Storage account or Keyvault.
https://learn.microsoft.com/en-us/powershell/module/az.resourcegraph/search-azgraph?view=azps-3.4.0