Get an access token using Azure CLI or Azure PowerShell

To use the FHIR service or the DICOM service, you need an access token that verifies your identity and permissions to the server. You can obtain an access token using PowerShell or the Azure Command-Line Interface (CLI), which are tools for creating and managing Azure resources.

Keep in mind that to access the FHIR service or the DICOM service, users and applications must be granted permissions through role assignments from Azure portal, or by using scripts.


Get an access token for the FHIR service

The FHIR service uses a specific resource or Audience with URI equal to the URI of the FHIR server https://<workspacename-fhirservicename>.fhir.azurehealthcareapis.com. Obtain a token and store it in a variable (named $token) with the following command:

token=$(az account get-access-token --resource=https://<workspacename-fhirservicename>.fhir.azurehealthcareapis.com --query accessToken --output tsv)
curl -X GET --header "Authorization: Bearer $token" https://<workspacename-fhirservicename>.fhir.azurehealthcareapis.com/Patient

Get an access token for the DICOM service

The DICOM service uses the same resource or Audience with URI equal to https://dicom.healthcareapis.azure.com to obtain an access token. Obtain a token and store it in a variable (named $token) with the following command:

token=$(az account get-access-token --resource=https://dicom.healthcareapis.azure.com --query accessToken --output tsv)
curl -X GET --header "Authorization: Bearer $token"  https://<workspacename-dicomservicename>.dicom.azurehealthcareapis.com/v<version of REST API>/changefeed

Next steps

Learn more about:

Access FHIR service using Postman

Access FHIR service using REST client

Access DICOM service using cURL

FHIR® is a registered trademark of HL7 and is used with the permission of HL7.