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

Azure存储表跨环境(DEV→SIT→UAT→PROD)迁移方案咨询

Azure存储表跨环境(DEV→SIT→UAT→PROD)迁移方案

针对你需要将DEV环境的Azure存储表(含结构和100行数据)迁移到SIT、UAT、PROD环境的需求,以下是几种可行方案:

一、Azure门户手动操作方式

适合小数据量的一次性迁移:

  • 导出DEV表数据:登录Azure门户,找到DEV环境的存储账户,进入「表服务」→「表」,选择目标Employee表,点击「导出」,选择存储容器保存导出的JSON/CSV文件(也可直接下载到本地)。
  • 创建目标表:在目标环境(比如SIT)的存储账户中,手动创建同名Employee表,确保列名、数据类型与DEV表完全一致。
  • 导入数据:在目标表的菜单中选择「导入」,指定之前导出的文件,完成数据导入。重复该流程即可迁移到UAT、PROD环境。

二、Azure CLI命令自动化迁移

适合批量或重复执行迁移,步骤如下:

  1. 导出DEV表数据到本地JSON文件:
az storage table entity query --account-name <DEV存储账户名> --account-key <DEV账户密钥> --table-name Employee --output json > employee-export.json
  1. 在目标环境创建Employee表(如果不存在):
az storage table create --account-name <目标存储账户名> --account-key <目标账户密钥> --name Employee
  1. 导入数据到目标表:
    需要提前安装jq工具解析JSON,然后循环插入实体:
cat employee-export.json | jq -c '.value[]' | while read entity; do az storage table entity insert --account-name <目标存储账户名> --account-key <目标账户密钥> --table-name Employee --entity "$entity"; done

三、PowerShell脚本迁移

适合熟悉PowerShell的用户,可编写脚本批量处理多环境迁移:

# DEV环境配置
$devStorageAccountName = "你的DEV存储账户名"
$devStorageAccountKey = "你的DEV账户密钥"
$devTableName = "Employee"

# 目标环境配置(替换为SIT/UAT/PROD的参数)
$targetStorageAccountName = "你的目标存储账户名"
$targetStorageAccountKey = "你的目标账户密钥"
$targetTableName = "Employee"

# 连接DEV存储账户
$devContext = New-AzStorageContext -StorageAccountName $devStorageAccountName -StorageAccountKey $devStorageAccountKey

# 获取DEV表所有数据实体
$entities = Get-AzStorageTableRow -table (Get-AzStorageTable -Name $devTableName -Context $devContext).CloudTable

# 连接目标存储账户并创建表(不存在则创建)
$targetContext = New-AzStorageContext -StorageAccountName $targetStorageAccountName -StorageAccountKey $targetStorageAccountKey
$targetTable = Get-AzStorageTable -Name $targetTableName -Context $targetContext -ErrorAction SilentlyContinue
if (-not $targetTable) {
    $targetTable = New-AzStorageTable -Name $targetTableName -Context $targetContext
}

# 批量导入数据
foreach ($entity in $entities) {
    Add-AzStorageTableRow -table $targetTable.CloudTable -Entity $entity
}

关于Azure Copy的说明

Azure Copy(az storage copy命令)不支持直接复制存储表,它主要用于Blob存储、文件共享等类型的复制操作,所以无法直接用它完成存储表的迁移,还是得用上面的导出/导入方案。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.28 04:05:19