重要
Azure API for FHIR 将于 2026 年 9 月 30 日停用。 按照迁移策略在该日期之前转换到 Azure Health Data Services FHIR® 服务。 由于 Azure API for FHIR 停用,在 2025 年 4 月 1 日开始前不会允许新的部署。
Azure Health Data Services FHIR 服务是 Azure API for FHIR 的演化版本,可让客户管理 FHIR、DICOM 和医疗技术服务,并集成到其他 Azure 服务。
在本快速入门中,你将了解如何使用 Azure 资源管理器模板(ARM 模板)部署适用于快速医疗保健互操作性资源 (FHIR®) 的 Azure API。 可以通过 Azure 门户、PowerShell 或 CLI 部署 Azure API for FHIR。
Azure 资源管理器模板是定义项目基础结构和配置的 JavaScript 对象表示法 (JSON) 文件。 模板使用声明性语法。 你可以在不编写用于创建部署的编程命令序列的情况下,描述预期部署。
如果你的环境满足先决条件,并且你熟悉如何使用 ARM 模板,请选择“部署到 Azure”按钮。 登录后,将在 Azure 门户中打开该模板。
先决条件
- 具有活动订阅的 Azure 帐户。 免费创建一个。
- 若要在本地运行代码,请安装:
查看模板
本快速入门中使用的模板来自 Azure 快速启动模板。
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.5.6.12127",
"templateHash": "9588053699595008971"
}
},
"parameters": {
"serviceName": {
"type": "string",
"metadata": {
"description": "The name of the service."
}
},
"___location": {
"type": "string",
"allowedValues": [
"australiaeast",
"eastus",
"eastus2",
"japaneast",
"northcentralus",
"northeurope",
"southcentralus",
"southeastasia",
"uksouth",
"ukwest",
"westcentralus",
"westeurope",
"westus2"
],
"metadata": {
"description": "Location of Azure API for FHIR"
}
}
},
"resources": [
{
"type": "Microsoft.HealthcareApis/services",
"apiVersion": "2021-11-01",
"name": "[parameters('serviceName')]",
"___location": "[parameters('___location')]",
"kind": "fhir-R4",
"properties": {
"authenticationConfiguration": {
"audience": "[format('https://{0}.azurehealthcareapis.com', parameters('serviceName'))]",
"authority": "[uri(environment().authentication.loginEndpoint, subscription().tenantId)]"
}
}
}
]
}
该模板定义了一个 Azure 资源。
- Microsoft.HealthcareApis/services
部署模板
选择以下链接以使用 Azure 门户中的 ARM 模板部署 Azure API for FHIR:
在“部署 Azure API for FHIR”页上:
如果需要,可以将“订阅”从默认值更改为其他订阅。
对于“资源组”,请选择“新建”,输入新资源组的名称,然后选择“确定” 。
如果创建了新的资源组,请为该资源组选择一个区域。
输入新的服务名称,然后选择 Azure API for FHIR 所在的位置。 该位置可以与资源组所在的区域相同,也可以与资源组所在的区域不同。

选择“查看 + 创建”。
阅读条款和条件,然后选择“创建”。
注意
若要在本地运行 PowerShell 脚本,请首先输入 Connect-AzAccount
来设置 Azure 凭据。
如果还没有为订阅注册 Microsoft.HealthcareApis
资源提供程序,则可以使用以下交互式代码进行注册。 若要在 Azure Cloud Shell 中运行该代码,请在任何代码块的右上角选择“尝试”。
Register-AzResourceProvider -ProviderNamespace Microsoft.HealthcareApis
使用以下代码通过 ARM 模板部署 Azure API for FHIR 服务。 该代码会提示你输入新的 FHIR 服务名称、新资源组的名称及其各自所在的位置。
$serviceName = Read-Host -Prompt "Enter a name for the new Azure API for FHIR service"
$serviceLocation = Read-Host -Prompt "Enter an Azure region (for example, westus2) for the service"
$resourceGroupName = Read-Host -Prompt "Enter a name for the new resource group to contain the service"
$resourceGroupRegion = Read-Host -Prompt "Enter an Azure region (for example, centralus) for the resource group"
Write-Verbose "New-AzResourceGroup -Name $resourceGroupName -Location $resourceGroupRegion" -Verbose
New-AzResourceGroup -Name $resourceGroupName -Location $resourceGroupRegion
Write-Verbose "Run New-AzResourceGroupDeployment to create an Azure API for FHIR service using an ARM template" -Verbose
New-AzResourceGroupDeployment -ResourceGroupName $resourceGroupName `
-TemplateUri https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/quickstarts/microsoft.healthcareapis/azure-api-for-fhir/azuredeploy.json `
-serviceName $serviceName `
-___location $serviceLocation
Read-Host "Press [ENTER] to continue"
如果还没有为订阅注册 Microsoft.HealthcareApis
资源提供程序,则可以使用以下交互式代码进行注册。 若要在 Azure Cloud Shell 中运行该代码,请在任何代码块的右上角选择“尝试”。
az extension add --name healthcareapis
使用以下代码通过 ARM 模板部署 Azure API for FHIR 服务。 该代码会提示你输入新的 FHIR 服务名称、新资源组的名称及其各自所在的位置。
read -p "Enter a name for the new Azure API for FHIR service: " serviceName &&
read -p "Enter an Azure region (for example, westus2) for the service: " serviceLocation &&
read -p "Enter a name for the new resource group to contain the service: " resourceGroupName &&
read -p "Enter an Azure region (for example, centralus) for the resource group: " resourceGroupRegion &&
params='serviceName='$serviceName' ___location='$serviceLocation &&
echo "CREATE RESOURCE GROUP: az group create --name $resourceGroupName --___location $resourceGroupRegion" &&
az group create --name $resourceGroupName --___location $resourceGroupRegion &&
echo "RUN az deployment group create, which creates an Azure API for FHIR service using an ARM template" &&
az deployment group create --resource-group $resourceGroupName --parameters $params --template-uri https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/quickstarts/microsoft.healthcareapis/azure-api-for-fhir/azuredeploy.json &&
read -p "Press [ENTER] to continue: "
注意
部署需要数分钟才能完成。 记下 Azure API for FHIR 服务和资源组名称,以在查看已部署资源时使用。
查看已部署的资源
按照以下步骤查看新 Azure API for FHIR 服务的概览:
在 Azure 门户中,搜索并选择“Azure API for FHIR”。
在 FHIR 列表中,选择你的新服务。 此时将显示新 Azure API for FHIR 服务的“概述”页。
若要验证是否预配了新的 FHIR API 帐户,请选择“FHIR 元数据终结点”旁边的链接,以提取 FHIR API 功能语句。 该链接的格式为 https://<service-name>.azurehealthcareapis.com/metadata
。 如果预配了帐户,则会显示一个 JSON 文件。
运行以下交互式代码来查看有关 Azure API for FHIR 服务的详细信息。 必须输入新服务的名称和资源组。
$serviceName = Read-Host -Prompt "Enter the name of your Azure API for FHIR service"
$resourceGroupName = Read-Host -Prompt "Enter the resource group name"
Write-Verbose "Get-AzHealthcareApisService -ResourceGroupName $resourceGroupName -Name $serviceName" -Verbose
Get-AzHealthcareApisService -ResourceGroupName $resourceGroupName -Name $serviceName
Read-Host "Press [ENTER] to fetch the FHIR API capability statement, which shows that the new service has been provisioned"
$requestUri="https://" + $serviceName + ".azurehealthcareapis.com/metadata"
$metadata = Invoke-WebRequest -Uri $requestUri
$metadata.RawContent
Read-Host "Press [ENTER] to continue"
运行以下交互式代码来查看有关 Azure API for FHIR 服务的详细信息。 必须输入新服务和资源组的名称。
read -p "Enter the name of your Azure API for FHIR service: " serviceName &&
read -p "Enter the resource group name: " resourceGroupName &&
echo "SHOW SERVICE DETAILS: az healthcareapis service show --resource-group $resourceGroupName --resource-name $serviceName" &&
az healthcareapis service show --resource-group $resourceGroupName --resource-name $serviceName &&
read -p "Press [ENTER] to fetch the FHIR API capability statement, which shows that the new service has been provisioned: " &&
requestUrl='https://'$serviceName'.azurehealthcareapis.com/metadata' &&
curl --url $requestUrl &&
read -p "Press [ENTER] to continue: "
清理资源
不再需要资源组时,可将其删除。 此操作会删除资源组中的资源。
在 Azure 门户中,搜索并选择“资源组”。
在资源组列表中,选择你的资源组的名称。
在资源组的“概览”页中,选择“删除资源组” 。
在确认对话框中,键入资源组的名称,然后选择“删除”。
$resourceGroupName = Read-Host -Prompt "Enter the name of the resource group to delete"
Write-Verbose "Remove-AzResourceGroup -Name $resourceGroupName" -Verbose
Remove-AzResourceGroup -Name $resourceGroupName
Read-Host "Press [ENTER] to continue"
read -p "Enter the name of the resource group to delete: " resourceGroupName &&
echo "DELETE A RESOURCE GROUP (AND ITS RESOURCES): az group delete --name $resourceGroupName" &&
az group delete --name $resourceGroupName &&
read -p "Press [ENTER] to continue: "
有关引导你完成 ARM 模板创建过程的分步教程,请参阅创建和部署第一个 ARM 模板教程
后续步骤
在本快速入门指南中,你已将 Azure API for FHIR 部署到订阅中。 有关如何注册应用程序和 Azure API for FHIR 配置设置的信息,请参阅以下内容。
注意
FHIR® 是 HL7 的注册商标,经 HL7 许可使用。