Search code examples
azurekubernetesazure-powershellazure-cliazure-oms

How to retrieve azure oms workspace id and key?


Is there a way to retrieve the oms workspace ID and Key in Azure via the az cli or azure powershell? I am deploying k8s clusters (in Azure) and automatically want to deploy the oms container agent via helm. I need a workspace ID and key for that and I don't want to create the workspace by hand and manually put the Id and Key in my release job :).


Solution

  • You could use Azure Power Shell to do this, for example:

    $rgname = "shuioms"
    $omsname = "shuioms"
    ##get workspaceid
    $oms=Get-AzureRmOperationalInsightsWorkspace -ResourceGroupName shuioms -Name shuioms
    $workspaceID = $oms.CustomerId
    #get oms key
    $key=Get-AzureRmOperationalInsightsWorkspaceSharedKeys -ResourceGroupName shuioms -Name shuioms