terça-feira, outubro 13, 2020

Log Analytics - API Access using PostMan

 In Azure AAD – App Registrations - Add a new Registration:

 

Give a name for your App:

Register, After that the App will be created:

Take note of the Application ID.

Go to API Permissions – Add a Permission - APIs my organization use look for “Log Analytics API” and select:


 Select Application Permissions, Select Data.Read and Add Permissions

 

Grant admin consent for directory:

Create a secret and copy the value

 Access Control:

Go to your Log Analytics workspace and add a Role assignment (Log Analytics Reader – and look for the Application name ):

Postman:

To access the Log Analytics API I use PostMan but you can use other tools, like PowerShell, Curl etc.

Download the Post Man:

https://www.postman.com/downloads/

In the PostMan create a Collection, in my example the name of colletion is “Noob”

The HTTP Method is POST:

The address is:

https://login.microsoftonline.com/XXXXXXXXXXXX/oauth2/token

Where XXXXXXXXXXXX is my Azure Active Directory ID

You can check your Azure Id in the App Registration ( Directory Tenant ID ):

 

grant_type=client_credentials

client_id=YOUR_CLIENT_ID

resource=https://api.loganalytics.io

client_secret=YOUR_CLIENT_SECRET 

Body:

 

Send and copy the access token :


You need to copy the value of the access token.

Create a new query in PostMan. The HTTP method is POST, where:

https://api.loganalytics.io/v1/workspaces/AAAAAAAA/query

Where AAAAAAA is my Log Analytics ID.

For check the ID go to Log Analytics and check the ID:


 

In the Authorization select “Bearer Token” and paste token that you got when you connect to API using Postman.


 Go to the Body:
And type this query (It is an example):
{
   "query": "Perf | where CounterName == 'Available MBytes' | summarize avg(CounterValue) by bin(TimeGenerated, 1h)",
        "timespan": "PT12H"
}

Select raw and JSON:

Send, then you will get the results:


segunda-feira, setembro 07, 2020

Windows Virtual Desktop - Add Host to a Pool (ARM)

 This is the steps to add a Virtual machine to an existent host pool.

I have three VMs on my current host pool:

 

I will added a new, host-3.

Requirements for the VM( host-3 ):

  • You must domain-join the machine. This allows incoming Windows Virtual Desktop users to be mapped from their Azure Active Directory account to their Active Directory account and be successfully allowed access to the virtual machine.
  • You must install the Remote Desktop Session Host (RDSH) role if the virtual machine is running a Windows Server OS. The RDSH role allows the Windows Virtual Desktop agents to install properly.

Install the Windows Virtual desktop agent:

https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RWrmXv

I created a small script to get the Registration token ( You need to add the Vm to a host pool ).

https://raw.githubusercontent.com/maykonrds/Wvd/master/Get-RegistrationInfo.ps1 

Install Windows Virtual Desktop Agent Bootloader

https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RWrxrH

Restart the VM and check in the Azure Portal: