Access the Azure Health Data Services with cURL
In this article, you learn how to access Azure Health Data Services with cURL.
Prerequisites
PowerShell
- An Azure account with an active subscription. Create one for free.
- If you want to run the code locally, install PowerShell and Azure Az PowerShell module PowerShell.
- Optionally, you can run the scripts in Visual Studio Code with the REST Client extension. For more information, see Make a link to the REST Client doc.
- Download and install cURL.
CLI
- An Azure account with an active subscription. Create one for free.
- If you want to run the code locally, install Azure CLI.
- Optionally, install a Bash shell, such as Git Bash, which is included in Git for Windows.
- Optionally, run the scripts in Visual Studio Code with the REST Client extension. For more information, see Make a link to the REST Client doc.
- Download and install cURL.
Obtain Azure Access Token
Before accessing the Azure Health Data Services, you must grant the user or client app with proper permissions. For more information on how to grant permissions, see Azure Health Data Services authorization.
There are several different ways to obtain an Azure access token for the Azure Health Data Services.
Note
Make sure that you have logged into Azure and that you are in the Azure subscription and tenant where you have deployed the Azure Health Data Services instance.
### check Azure environment and PowerShell versions
Get-AzContext
Set-AzContext -Subscription <subscriptionid>
$PSVersionTable.PSVersion
Get-InstalledModule -Name Az -AllVersions
curl --version
### get access token for the FHIR service
$fhirservice="https://<fhirservice>.fhir.azurehealthcareapis.com"
$token=(Get-AzAccessToken -ResourceUrl $fhirservice).Token
### Get access token for the DICOM service
$dicomtokenurl= "https://dicom.healthcareapis.azure.com/"
$token=$( Get-AzAccessToken -ResourceUrl $dicomtokenurl).Token
Note
When the FHIR® service audience parameter is not mapped to the FHIR service endpoint url, the resource parameter value should be mapped to Audience value under the FHIR Service Authentication blade.
Access data in the FHIR service
$fhirservice="https://<fhirservice>.fhir.azurehealthcareapis.com"
curl -X GET --header "Authorization: Bearer $token" $fhirservice/Patient
Access data in the DICOM service
$dicomservice="https://<dicomservice>.dicom.azurehealthcareapis.com"
curl -X GET --header "Authorization: Bearer $token" $dicomservice/changefeed?includemetadata=false
Next steps
In this article, you learned how to access Azure Health Data Services data using cURL.
To learn about how to access Azure Health Data Services data using REST Client extension in Visual Studio Code, see
Note
FHIR® is a registered trademark of HL7 and is used with the permission of HL7.