You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure SQL Database 2014版API将退役:如何排查并升级资源?

Azure SQL Database 旧版API退役排查与升级指南

一、排查使用旧版API的资源及升级操作

修正Kusto查询语句

你之前的查询报错是因为TIMESTAMP列名错误,且使用了不正确的表。Azure Resource Graph中应使用AzureActivity表追踪API调用,正确的查询语句如下:

AzureActivity
| where TimeGenerated > ago(30d)
| where ResourceProviderValue == 'MICROSOFT.SQL'
| where SubscriptionId == '<subscription-id>'
| where OperationNameValue contains 'MICROSOFT.SQL'
| where Properties has 'apiVersion'
| extend apiVersion = parse_json(Properties).apiVersion
| where apiVersion in ("2014-04-01", "2014-01-01", "2014-04-01-preview")
| project TimeGenerated, SubscriptionId, ResourceGroup, Resource, OperationNameValue, apiVersion, Caller

Azure门户操作步骤

  1. 登录Azure门户,搜索并进入Resource Graph Explorer
  2. 将上述查询中的<subscription-id>替换为你的订阅ID,粘贴到查询编辑器中
  3. 点击运行按钮,查询结果会展示过去30天内使用旧版API调用SQL资源的详细记录,包括调用者、目标资源、操作类型等信息

升级说明

需要升级的不是SQL Server本身,而是所有调用该服务器的模板、脚本、应用程序中的API版本,将其切换到2014-04-01之后的稳定版本(推荐使用2021-11-01或更高版本)。确保所有旧版API调用替换完成后,即可避免2025年10月31日之后的服务中断。

二、需升级资源示例

ARM模板

修改模板中Microsoft.Sql/servers资源的apiVersion字段:
旧片段:

{
  "type": "Microsoft.Sql/servers",
  "apiVersion": "2014-04-01",
  "name": "[parameters('serverName')]",
  ...
}

新片段:

{
  "type": "Microsoft.Sql/servers",
  "apiVersion": "2021-11-01",
  "name": "[parameters('serverName')]",
  ...
}

PowerShell脚本

更新Az.Sql模块到最新版本,并移除或修改旧版ApiVersion参数:
旧命令:

New-AzSqlServer -ResourceGroupName "myRG" -ServerName "myServer" -Location "East US" -SqlAdministratorCredentials $cred -ApiVersion "2014-04-01"

新命令:

# 推荐更新Az模块后使用默认最新API版本
New-AzSqlServer -ResourceGroupName "myRG" -ServerName "myServer" -Location "East US" -SqlAdministratorCredentials $cred
# 或显式指定新版API
New-AzSqlServer -ResourceGroupName "myRG" -ServerName "myServer" -Location "East US" -SqlAdministratorCredentials $cred -ApiVersion "2021-11-01"

Azure CLI命令

更新Azure CLI到最新版本,移除或修改旧版--api-version参数:
旧命令:

az sql server create --resource-group myRG --name myServer --location eastus --admin-user myadmin --admin-password mypass --api-version 2014-04-01

新命令:

# 使用默认最新API版本
az sql server create --resource-group myRG --name myServer --location eastus --admin-user myadmin --admin-password mypass
# 或显式指定新版API
az sql server create --resource-group myRG --name myServer --location eastus --admin-user myadmin --admin-password mypass --api-version 2021-11-01

自定义应用程序(以C#为例)

更新Azure SDK包到最新版本(推荐使用Azure.ResourceManager.Sql),新版SDK默认使用最新API版本:
旧代码片段:

var server = new Server("myServer")
{
  Location = "East US",
  AdministratorLogin = "myadmin",
  AdministratorLoginPassword = "mypass"
};
await sqlManagementClient.Servers.CreateOrUpdateAsync("myRG", "myServer", server, "2014-04-01");

新代码片段:

var client = new SqlManagementClient(new DefaultAzureCredential());
var serverData = new ServerData("East US")
{
  AdministratorLogin = "myadmin",
  AdministratorLoginPassword = "mypass"
};
await client.Servers.CreateOrUpdateAsync(WaitUntil.Completed, "myRG", "myServer", serverData);

内容的提问来源于stack exchange,提问作者Wendy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 14:29:59