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

时间:2019-01-24 13:47:51

标签: azure azure-devops azure-powershell

当我在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.

Run a PowerShell script within the Azure environment

这是我运行的脚本:

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管道使删除正常运行?

1 个答案:

答案 0 :(得分:1)

发生这种情况是因为其要求确认删除(-fno-short-enums),您丢失了:`。

user@host:~$ echo '_Static_assert(4 == sizeof(enum{E}), "enum size is not 4");' | x86_64-linux-gnu-gcc -fsyntax-only -xc - && echo "OK, enum size is 4 on x86_64-linux-gnu"
OK, enum size is 4 on x86_64-linux-gnu

user@host:~$ echo '_Static_assert(4 == sizeof(enum{E}), "enum size is not 4");' | arm-linux-gnueabihf-gcc -fsyntax-only -xc - && echo "OK, enum size is 4 on arm-linux-gnueabihf"
OK, enum size is 4 on arm-linux-gnueabihf

user@host:~$ echo '_Static_assert(4 == sizeof(enum{E}), "enum size is not 4");' | /opt/Atollic_TrueSTUDIO_for_STM32_x86_64_9.1.0/ARMTools/bin/arm-atollic-eabi-gcc -fsyntax-only -xc -
<stdin>:1:1: error: static assertion failed: "enum size is not 4"

user@host:~$ echo '_Static_assert(4 == sizeof(enum{E}), "enum size is not 4");' | /opt/Atollic_TrueSTUDIO_for_STM32_x86_64_9.1.0/ARMTools/bin/arm-atollic-eabi-gcc -fno-short-enums -fsyntax-only -xc - && echo "OK, enum size is 4 on arm-atollic-eabi with -fno-short-enums"
OK, enum size is 4 on arm-atollic-eabi with -fno-short-enums

只是重新测试了一下,如果您提供-fshort-enums

,它将在没有提示的情况下工作