【发布时间】:2020-09-12 23:48:30
【问题描述】:
更新:
在 Maurad 发表评论后,我发现一个日志显示“CreateContainer”操作似乎在不同的 IP 下运行 ???????? 知道为什么会发生这种情况吗?
原帖:
我有一个启用了防火墙的 Azure 存储帐户,我正在尝试使用 VSTS 构建管道在该帐户中创建一个 Blob 容器。
管道由 Microsoft 托管代理运行,因此在创建容器之前将机器的 IP 添加到防火墙并在之后将其删除是我过程的一部分。
问题是我在运行 create blob 命令时收到错误 403。
我尝试在将 ip 添加到防火墙后添加等待时间,但即使等待 5 分钟,我仍然得到 403。
这是我正在运行的脚本:
$MyIP = (Invoke-WebRequest 'https://ifconfig.me/ip' -Method Get).Content
Try {
Add-AzStorageAccountNetworkRule -ResourceGroupName $ResourceGroupName `
-Name $StorageAccountName `
-IPAddressOrRange $MyIP
$ctx = (Get-AzStorageAccount -ResourceGroupName $ResourceGroupName `
-Name $StorageAccountName).Context
New-AzStorageContainer -Name $ContainerName `
-Context $ctx
}
Finally {
Remove-AzStorageAccountNetworkRule -ResourceGroupName $ResourceGroupName `
-Name $StorageAccountName `
-IPAddressOrRange $MyIP
}
这是我得到的结果(你可以看到代理的ip被正确添加了)
Action IPAddressOrRange
------ ----------------
Allow 127.0.0.1
Allow 104.40.203.123 # This is the build agent IP
New-AzStorageContainer: C:\Users\Desktop\Test.ps1:15
Line |
15 | New-AzStorageContainer -Name $ContainerName `
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| This request is not authorized to perform this operation. HTTP Status Code: 403 - HTTP Error Message:
| This request is not authorized to perform this operation.
ErrorCode: AuthorizationFailure
| ErrorMessage: This request is not authorized to perform this operation.
| RequestId:9112d81a-e01e-002a-7935-331d33000000
Time:2020-05-26T08:11:04.9195569Z
Action IPAddressOrRange
------ ----------------
Allow 127.0.0.1
备注:禁用防火墙有效,但我不能在 prod 中这样做
【问题讨论】:
-
如果您在存储帐户上配置了存储分析,则可以检查分析日志以查看创建 Blob 容器的请求来自哪个 IP 地址。
-
我没有,但我可以做到。我会尝试更新我的发现。谢谢
-
我没有在我的分析中看到任何有关源 IP 地址的信息。仅限使用指标。
-
您是否在您的存储帐户中看到
$logs容器(您需要使用 Microsoft 存储资源管理器)?在那里您将看到分析日志。有关更多信息,请参阅此内容:docs.microsoft.com/en-us/rest/api/storageservices/…。 -
找到了!谢谢!您似乎是对的????,由于某些非常奇怪的原因,“CreateContainer”操作具有与所有其他操作不同的 IP。知道为什么会这样吗?
标签: azure powershell azure-storage azure-blob-storage azure-powershell