繁体   English   中英

如何通过Azure DevOps从Azure删除存储帐户

[英]How to remove a storage account from Azure through Azure DevOps

在Azure PowerShell任务中运行Remove-AzureRmStorageAccount命令时,出现此错误:

2019-01-24T13:07:29.0148404Z ==============================================================================
2019-01-24T13:07:29.0148533Z Task         : Azure PowerShell
2019-01-24T13:07:29.0148602Z Description  : Run a PowerShell script within an Azure environment
2019-01-24T13:07:29.0148688Z Version      : 3.1.18
2019-01-24T13:07:29.0148847Z Author       : Microsoft Corporation
2019-01-24T13:07:29.0148947Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=613749)
2019-01-24T13:07:29.0149050Z ==============================================================================
2019-01-24T13:07:30.2233628Z ##[command]Import-Module -Name C:\Program Files\WindowsPowerShell\Modules\AzureRM\6.13.1\AzureRM.psd1 -Global
2019-01-24T13:07:42.1447157Z ##[command]Clear-AzureRmContext -Scope Process
2019-01-24T13:07:42.7204663Z ##[command]Disable-AzureRmContextAutosave -ErrorAction SilentlyContinue
2019-01-24T13:07:43.0466903Z ##[command]Add-AzureRMAccount -ServicePrincipal -Tenant *** -Credential System.Management.Automation.PSCredential -Environment AzureCloud @processScope
2019-01-24T13:07:44.1568578Z ##[command] Select-AzureRMSubscription -SubscriptionId XXXXX -TenantId ***
2019-01-24T13:07:44.5546953Z ##[command]& 'D:\a\_temp\XXXXX.ps1' 
2019-01-24T13:07:44.6950579Z ##[command]Disconnect-AzureRmAccount -Scope Process
2019-01-24T13:07:45.1149833Z ##[command]Clear-AzureRmContext -Scope Process
2019-01-24T13:07:45.5569262Z ##[error]Windows PowerShell is in NonInteractive mode. Read and Prompt functionality is not available.

在Azure环境中运行PowerShell脚本

这是我运行的脚本:

Remove-AzureRmStorageAccount `
    -ResourceGroupName "myResourceGroupName" `
    -AccountName "mystorageaccountname"
    -Force

请注意,我可以用相同的方式创建存储帐户和blob容器,而不会出错。 该脚本可以正常工作:

if(Get-AzureRmStorageAccountNameAvailability -Name "mystorageaccountname")
{
  New-AzureRmStorageAccount `
    -ResourceGroupName "myResourceGroupName" `
    -AccountName "mystorageaccountname" `
    -Location "West Europe" `
    -SkuName "Standard_LRS"

  New-AzureRmStorageContainer `
    -ResourceGroupName "myResourceGroupName" `
    -AccountName "mystorageaccountname" `
    -ContainerName "my-blob-container" `
    -PublicAccess "Blob"
}

如何通过Azure DevOps管道使删除正常运行而没有错误?

发生这种情况是因为其要求确认删除( ##[error]Windows PowerShell is in NonInteractive mode. Read and Prompt functionality is not available ),您丢失了:`。

Remove-AzureRmStorageAccount `
    -ResourceGroupName "myResourceGroupName" `
    -AccountName "mystorageaccountname" ` <<<<< here
    -Force

刚刚重新测试过,如果您提供-Force ,它将在没有提示的情况下工作

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM