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
Related
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
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
Is these any way to run Azure CLI commands in Azure Automation Account Python Runbooks or powershell runbooks !
I have few Azure CLI commands which were working perfectly fine in local PowerShell. I need to run same Azure CLI commands in Azure Automation Account Python Runbooks or in PowerShell runbooks.
I dont think there is any native way to run Azure Cli commands in Azure Automation Runbook. You can use Azure Container Instances to work around that, but most of the things CLI can do Azure Powershell\Python can do as well, so you can use a native way of doing that.
I have a few resource groups in my Azure subscription. Is there an Azure CLI Powershell script / command ---- to find all/any services that are being used which are in [Preview] and are not [Generally Available].
AFAIK, there is no way to do that via powershell or cli.
If you want to know if a service is in preview or generally available, check out https://azure-overview.com/.
Is it possible to restart an instance of an Azure Cloud Service through the Azure CLI?
Azure CLI command reference here. I have seen options for restarting a vm, a vmss, a function app, a service fabric node and a web app.
Note: It is not possible to restart an instance of an Azure Cloud Services through Azure CLI.
As Walter said, you can use Azure CLI 1.0 to create and manage Azure Cloud Service, but you cannot restart an instance.
You may check the available options for Azure Cloud Service with Azure CLI 1.0:
Azure CLI Options for Cloud Services
You may use Azure PowerShell to restart an instance of an Cloud Services:
PS C:> ReSet-AzureRoleInstance -ServiceName "MySvc01" -Slot "Staging" -InstanceName "MyWebRole_IN_0" -Reboot
Is it possible to restart an instance of an Azure Cloud Service
through the Azure CLI?
Based on my knowledge, it is not possible.
Azure Cloud Service is a Classic mode service. However, Azure CLI 2.0 is optimized for managing and administering Azure resources from the command line, and for building automation scripts that work against the Azure Resource Manager. ASM/Classic mode is not supported in the Azure CLI 2.0. Please refer to this link.
Azure Cli 1.0 supports ASM mode and Cloud Service.