Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Powershell从Microsoft Azure恢复已删除的容器?_Azure_Powershell_Azure Container Service_Soft Delete_Recover - Fatal编程技术网

如何使用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

我正在尝试使用Azure Powershell将软删除的容器恢复到Microsoft Azure中的存储帐户中


实际上,在门户中,我们可以手动执行此操作,但我没有通过使用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 }