- Make sure you have the latest version of the
Az
PowerShell module (>= 4.1)
First create a resource group if you do not have one:
New-AzResourceGroup -Location <location> -Name <resource group name>
Create FHIR API:
$fhirApi = Get-AzHealthcareApisService -name <fhir service name> -ResourceGroupName <resource group name>
Then create service principal with data plane privileges:
$sp = New-AzADServicePrincipal -DisplayName "mihansen-fhir-api-sp" -Role "FHIR Data Contributor" -Scope $fhirApi.Id
And to get all the details:
$details = @{
clientId = $sp.Id
clientSecret = $(New-Object PSCredential "user",$sp.secret).GetNetworkCredential().Password
fhirServerUrl = "https://" + $fhirApi.Name + ".azurehealthcareapis.com"
tokenUrl = $fhirApi.Audience + "/oauth2/v2.0/token"
scope = $fhirApi.Audience + "/user_impersonation"
}
# Print the details
$details