Possible to enable diagnostic settings when creating an Azure VM via CLI? - azure

I haven't found a command line switch for enabling diagnostic settings when creating a VM with the Azure CLI.
I know it works in the portal, but likely this is a separate step in the deployment template.
However, there is a new command line switch for enabling log analytics workspace immediately (Preview).

az vm create cli does not provide the arguments about diagnostic settings, so I am afraid that we cannot enable diagnostic settings when creating an azure vm.
As workaround, you can try to enable the diagnostics settings using Azure CLI by following this document.
az vm diagnostics set --settings
[--ids]
[--no-auto-upgrade {false, true}]
[--protected-settings]
[--resource-group]
[--subscription]
[--version]
[--vm-name]
Here is a case on github you can refer to .

Related

Create an Azure DevOps organization through Azure CLI

I want to create a new Azure DevOps organization with the az command line.
I have installed the devops extension.
I have read the Microsoft documentation and it describes how to create an organization through web interface, but there is nothing described for command line.
I have also read the documentation of az and az devops extension.
Have I missed something?
I am afraid currently it is not supported to create Azure DevOps organization via az devops command line or the DevOps REST API.
However, you can use Azure CLI az resource create to create a resource of type microsoft.visualstudio/account as a workaround. This will create an Azure DevOps organization. For example:
az resource create -g AzureResourceGroup -n MyDevopsOrganizationName `
--resource-type microsoft.visualstudio/account --is-full-object `
--properties '{\"location\":\"Central Us\", \"properties\":{ \"operationType\": \"Create\"}}'
The command above creates Azure DevOps organization MyDevopsOrganizationName.
https://MyDevopsOrganizationName.visualstudio.com
You can also use an ARM template to create an Azure DevOps organization.

How can i Turn On/Off "Https only" for Azure AppService using Azure DevOps Pipeline?

I Have an Azure Release Pipeline for my website. For one of the task in that Release Pipeline, i need to disable HTTPS ONLY option (its is available under SSL/TLS Blade in Azure Portal check below image). After that task is executed i want to turn ON that "HTTPS ONLY" again.
Is there a simple way simple way to do that?
PS: i have reviewed this question
already but i don't want to use ARM Template
You may use Azure CLI and Azure CLI task to achieve this. Here is the command:
az webapp update --resource-group <YourResourceGroupName> --name <YourWebAppName> --set HttpsOnly=true

Error while applying Node Autoscaler for existing AKS cluster

I am trying to experiment with Preview feature available in Azure AKS as per documentation available we need to have the following requirements
Kubernetes version 1.12.4 or later
Azure CLI version 2.0.55 or later.
add aks preview :- az extension add --name aks-preview
register scale set provider:- az feature register --name VMSSPreview --namespace Microsoft.ContainerService
ensure that it is registerd
created AKS cluster with terraform
when i try to apply following command
az aks update --resource-group rg-euwest-d04-dvag-001 --name k8s-euwest-d04-dvag-dfs-dfsapp-001 --enable-cluster-autoscaler --min-count 3 --max-count 5
error
Operation failed with status: 'Bad Request'. Details: AgentPool
'' has set auto scaling as enabled but is not on Virtual
Machine Scale Sets, this is not allowed
As per my understanding, it is not supported at this time through terraform or from Azure Portal but only possible from Azure CLI
Your cluster needs to be created via Azure CLI to enable autoscaling. So if you have created on evia Azure portal, you need to delete it and create new one through Azure CLI. Ref: https://github.com/MicrosoftDocs/azure-docs/issues/29199

Add Application Insights to an azure function with Azure CLI

I have a PowerShell script which creates an azure function app on a consumption plan and its associated storage account within a resource group using the azure cli following the example In the Microsoft Docs
However to enable application insights I have to go to the azure portal, find the func select monitor and click enable application insights.
How can I expand that script to enable automate this step for the newly created function? I have been unable to find any specific documentation or examples and I would prefer to avoid resource templates if possible.
OF course, you could enable Application Insights to the azure function by Azure CLI.
But you need to create the Application Insights in the portal first, currently, it is unable to create Application Insights via Azure CLI.
You could follow the steps below.
1.Go to your Application Insights in the portal, copy the Instrumentation Key in the screenshot.
2.After creating the function app by your command , just use the CLI command below.
az functionapp config appsettings set --name <functionname> --resource-group <resourcegroupname> --settings 'APPINSIGHTS_INSTRUMENTATIONKEY = <Instrumentation Key>'
It works fine on my side, you could check it in the portal.

Azure Custom Logs general availability date

As per OMS portal Azure Custom logs are in preview mode. I am not able to find any link, providing an expected date of general availability. Can neone help me with that ??
Also I am not able to find any link providing information on how to activate custom logs for a virtual machine scale set ? Other than log analytics? is there is any way to capture custom logs ??
Currently, Custom Logs is in preview, you need enable it on OMS Portal firstly.
More information about this you could check this question.
If you want to collect log from VMSS, you need install oms agent on it. You could use CLI to do this, for Linux:
az vmss extension set --name OmsAgentForLinux --publisher Microsoft.EnterpriseCloud.Monitoring --resource-group <nameOfResourceGroup> --vmss-name <nameOfNodeType> --settings "{'workspaceId':'<OMSworkspaceId>'}" --protected-settings "{'workspaceKey':'<OMSworkspaceKey>'}"
For Windows:
az vmss extension set --name MicrosoftMonitoringAgent --publisher Microsoft.EnterpriseCloud.Monitoring --resource-group <nameOfResourceGroup> --vmss-name <nameOfNodeType> --settings "{'workspaceId':'<OMSworkspaceId>'}" --protected-settings "{'workspaceKey':'<OMSworkspaceKey>'}"
More information about Custom logs in Log Analytics you could check this official document.

Resources