Get access token using Azure CLI or Azure PowerShell
Important
Azure Healthcare APIs is currently in PREVIEW. The Supplemental Terms of Use for Microsoft Azure Previews include additional legal terms that apply to Azure features that are in beta, preview, or otherwise not yet released into general availability.
In this article, you'll learn how to obtain an access token for the FHIR service and the DICOM service using PowerShell and the Azure CLI. Keep in mind that in order to access the FHIR service or the DICOM service, users and applications must be granted permissions through role assignments from the Azure portal or using scripts. For more details on how to get started with the Healthcare APIs, see How to get started with FHIR or How to get started with DICOM.
Obtain and use 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>.azurehealthcareapis.com. You can 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>.azurehealthcareapis.com --query accessToken --output tsv)
curl -X GET --header "Authorization: Bearer $token" https://<workspacename-fhirservicename>.azurehealthcareapis.com/Patient
Obtain and use 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. You can 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
In this article, you learned how to obtain an access token for the FHIR service and DICOM service using CLI and Azure PowerShell. For more details about accessing the FHIR service and DICOM service, see