如何使用Powershell从Microsoft Azure恢复已删除的容器?
我正在尝试使用Azure Powershell将软删除的容器恢复到Microsoft Azure中的存储帐户中如何使用Powershell从Microsoft Azure恢复已删除的容器?,azure,powershell,azure-container-service,soft-delete,recover,Azure,Powershell,Azure Container Service,Soft Delete,Recover,我正在尝试使用Azure Powershell将软删除的容器恢复到Microsoft Azure中的存储帐户中 实际上,在门户中,我们可以手动执行此操作,但我没有通过使用powershell命令找到解决方案,我只是通过将容器还原到以前的某个时间找到了解决方案,因此它也会恢复软删除的blob,但它仍然无法恢复软删除的容器。我试图找到直接取消删除容器的方法,但它似乎并不存在 有一种解决方法可以使用Powershell调用 这是代码示例: # login Connect-AzAccount # ge
实际上,在门户中,我们可以手动执行此操作,但我没有通过使用powershell命令找到解决方案,我只是通过将容器还原到以前的某个时间找到了解决方案,因此它也会恢复软删除的blob,但它仍然无法恢复软删除的容器。我试图找到直接取消删除容器的方法,但它似乎并不存在 有一种解决方法可以使用Powershell调用 这是代码示例:
# login
Connect-AzAccount
# get accessToken
$resource = "https://storage.azure.com"
$context = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile.DefaultContext
$accessToken = [Microsoft.Azure.Commands.Common.Authentication.AzureSession]::Instance.AuthenticationFactory.Authenticate($context.Account, $context.Environment, $context.Tenant.Id.ToString(), $null, [Microsoft.Azure.Commands.Common.Authentication.ShowDialog]::Never, $null, $resource).AccessToken
#request REST API
$uri = "{Request URI}"
Invoke-RestMethod -Method 'Put' -Uri $uri -Headers @{ Authorization = "Bearer " + $accessToken }
您需要添加以使其工作
# login
Connect-AzAccount
# get accessToken
$resource = "https://storage.azure.com"
$context = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile.DefaultContext
$accessToken = [Microsoft.Azure.Commands.Common.Authentication.AzureSession]::Instance.AuthenticationFactory.Authenticate($context.Account, $context.Environment, $context.Tenant.Id.ToString(), $null, [Microsoft.Azure.Commands.Common.Authentication.ShowDialog]::Never, $null, $resource).AccessToken
#request REST API
$uri = "{Request URI}"
Invoke-RestMethod -Method 'Put' -Uri $uri -Headers @{ Authorization = "Bearer " + $accessToken }