共用方式為

更新 AD DS 中的存储帐户标识密码

当您将存储帐户加入到 Active Directory 域服务 (AD DS) 时,需要创建一个带有密码的 AD 主体(计算机帐户或服务帐户)。 AD 主体的密码是存储帐户的 Kerberos 密钥之一。 根据 AD 主体的组织单位的密码策略,必须定期轮换 AD 主体的密码以避免身份验证问题。 在密码过期之前未能更改密码可能会使您的 Azure 文件共享失去 Kerberos 身份验证。 某些 AD 环境还可以使用自动清理脚本删除具有过期密码的 AD 主体。

还可以将表示存储帐户的 AD 主体放入不需要密码轮换的组织单位,而不是定期轮换密码。

有两个选项用于触发密码轮换。 可以使用 AzFilesHybrid 模块或 Active Directory PowerShell。 请使用一种方法,而不是同时使用两种方法。

适用于

管理模型 计费模式 媒体层 冗余 SMB NFS
Microsoft.Storage 预配 v2 HDD(标准) 本地 (LRS) 是 否
Microsoft.Storage 预配 v2 HDD(标准) 区域 (ZRS) 是 否
Microsoft.Storage 预配 v2 HDD(标准) 异地 (GRS) 是 否
Microsoft.Storage 预配 v2 HDD(标准) GeoZone (GZRS) 是 否
Microsoft.Storage 预配版本 v1 SSD(高级) 本地 (LRS) 是 否
Microsoft.Storage 预配版本 v1 SSD(高级) 区域 (ZRS) 是 否
Microsoft.Storage 即用即付 HDD(标准) 本地 (LRS) 是 否
Microsoft.Storage 即用即付 HDD(标准) 区域 (ZRS) 是 否
Microsoft.Storage 即用即付 HDD(标准) 异地 (GRS) 是 否
Microsoft.Storage 即用即付 HDD(标准) GeoZone (GZRS) 是 否

选项 1:使用 AzFilesHybrid 模块

若要重新生成并轮换表示存储帐户的 AD 主体的密码,请使用 Update-AzStorageAccountADObjectPasswordAzFilesHybrid 模块中的 cmdlet。 若要执行 Update-AzStorageAccountADObjectPassword,必须:

  • 从加入域的客户端运行 cmdlet。
  • 拥有存储帐户的所有者权限。
  • 具有 AD DS 权限以更改表示存储帐户的 AD 主体的密码。
# Update the password of the AD DS account registered for the storage account
# You may use either kerb1 or kerb2
Update-AzStorageAccountADObjectPassword `
        -RotateToKerbKey kerb2 `
        -ResourceGroupName "<your-resource-group-name-here>" `
        -StorageAccountName "<your-storage-account-name-here>"

轮换到 kerb2 后,建议等待几个小时,并再次使用 Update-AzStorageAccountADObjectPassword cmdlet 重新生成和轮换回 kerb1,以便重新生成这两个 Kerberos 密钥。

选项 2:使用 Active Directory PowerShell

如果不想下载 AzFilesHybrid 模块,可以使用 Active Directory PowerShell

重要

本部分中的 Windows Server Active Directory PowerShell cmdlet 必须由用户使用提升的特权在 Windows PowerShell 5.1 中运行。

将以下脚本中的 <domain-object-identity> 替换为你的环境的相应值:

$KeyName = "kerb1" # Could be either the first or second Kerberos key, this script assumes we're refreshing the first
$KerbKeys = New-AzStorageAccountKey -ResourceGroupName $ResourceGroupName -Name $StorageAccountName -KeyName $KeyName
$KerbKey = $KerbKeys.keys | Where-Object {$_.KeyName -eq $KeyName} | Select-Object -ExpandProperty Value
$NewPassword = ConvertTo-SecureString -String $KerbKey -AsPlainText -Force

Set-ADAccountPassword -Identity <domain-object-identity> -Reset -NewPassword $NewPassword

测试 AD DS 帐户密码是否与 Kerberos 密钥匹配

更新 AD DS 帐户密码后,可以使用以下 PowerShell 命令对其进行测试。

 Test-AzStorageAccountADObjectPasswordIsKerbKey -ResourceGroupName "<your-resource-group-name>" -Name "<your-storage-account-name>" -Verbose