存储帐户阻止容器创建的网络规则
Network Rules of storage account blocking container creation
按照 the Azure CLI "quickstart" on creating a blob 的说明进行操作。
看起来默认存储帐户中的某些东西阻止了创建新容器的能力;然而,"defaultAction"
是 Allow
:
以下 Azure CLI:
az storage container create --account-name meaningfulname --name nancy --auth-mode login
...导致错误解释存储帐户的网络规则可能是原因:
The request may be blocked by network rules of storage account. Please check network rule set using 'az storage account show -n accountname --query networkRuleSet'.
If you want to change the default action to apply when no rule matches, please use 'az storage account update'.
使用上述消息中的建议,对帐户名执行 "show" 命令会得到:
> az storage account show -n meaningfulname --query networkRuleSet
{
"bypass": "AzureServices",
"defaultAction": "Allow",
"ipRules": [],
"virtualNetworkRules": []
}
我认为 Azure CLI 属于 "services" 之一,可以 绕过 并执行操作。而且,默认操作在我看来是相当宽松的。
我已经完成了通过错误消息和命令(和变体)进行搜索的工作。似乎没有太多关于 Azure CLI 的怪癖我不知道的东西,所以也许这很明显以至于人们没有写任何东西。我不认为我在复制
目前的networkRuleSet
配置已经足够了。我无法使用与您相同的 networkRuleSet
配置重现此问题。因此,您可以在创建容器或查询 networkRuleSet
.
时仔细检查存储帐户是否存在拼写错误
默认情况下,存储帐户接受来自任何网络上的客户端的连接。要限制对选定网络的访问,您必须先更改默认操作。
如果您只需要允许从某些特定 IP 地址或特定子网访问您的存储帐户并允许 Azure 服务,您可以这样添加,
{
"bypass": "AzureServices",
"defaultAction": "Deny",
"ipRules": [
{
"action": "Allow",
"ipAddressOrRange": "100.100.100.100"
}
],
"virtualNetworkRules": [
{
"action": "Allow",
"virtualNetworkResourceId": "subnetID"
}
]
}
使用 Azure CLI,将默认规则设置为默认允许网络访问。
az storage account update --resource-group "myresourcegroup" --name "mystorageaccount" --default-action Deny
az storage account update --resource-group "myresourcegroup" --name "mystorageaccount" --default-action Allow
有关详细信息,请参阅 Change the default network access rule。
编辑
在这种情况下,您设置 --auth-mode
参数以登录到 authorize with Azure AD credentials. You need to ensure that the Azure AD security principal with which you sign in to Azure CLI has permission to do data operations against Blob or Queue storage. For more information about RBAC roles in Azure Storage, see Manage access rights to Azure Storage data with RBAC。
不确定这是否有帮助...
如果您使用 CLI 更新存储帐户的“防火墙和虚拟网络”部分并使其可供所有网络访问,则需要一些时间才能生效。我观察到它需要大约 10 -30 秒才能生效。
尝试等待 30 秒,然后尝试 az container create 语句。它应该有效。
虽然选择的答案不同
可能还有其他原因,比如我的情况。如 Microsoft 文档 here
所述,您需要成为该角色才能创建容器
Before you create the container, assign the Storage Blob Data
Contributor role to yourself. Even though you are the account owner,
you need explicit permissions to perform data operations against the
storage account.
另请注意
Azure role assignments may take a few minutes to propagate.
从您的命令中删除 --auth-mode login
。像这样使用它:
az storage container create \
--account-name helloworld12345 \
--name images \
--public-access container
如果我们不设置--auth-mode
,它使用默认的授权模式key
。它将查询存储帐户中的帐户密钥
https://docs.microsoft.com/en-us/azure/storage/blobs/authorize-data-operations-cli
如果您在命令中需要 RBAC 角色,请使用 --auth-mode login
。有关存储中 RBAC 角色的更多信息,请访问 https://docs.microsoft.com/en-us/azure/storage/common/storage-auth-aad-rbac-cli。
按照 the Azure CLI "quickstart" on creating a blob 的说明进行操作。
看起来默认存储帐户中的某些东西阻止了创建新容器的能力;然而,"defaultAction"
是 Allow
:
以下 Azure CLI:
az storage container create --account-name meaningfulname --name nancy --auth-mode login
...导致错误解释存储帐户的网络规则可能是原因:
The request may be blocked by network rules of storage account. Please check network rule set using 'az storage account show -n accountname --query networkRuleSet'.
If you want to change the default action to apply when no rule matches, please use 'az storage account update'.
使用上述消息中的建议,对帐户名执行 "show" 命令会得到:
> az storage account show -n meaningfulname --query networkRuleSet
{
"bypass": "AzureServices",
"defaultAction": "Allow",
"ipRules": [],
"virtualNetworkRules": []
}
我认为 Azure CLI 属于 "services" 之一,可以 绕过 并执行操作。而且,默认操作在我看来是相当宽松的。
我已经完成了通过错误消息和命令(和变体)进行搜索的工作。似乎没有太多关于 Azure CLI 的怪癖我不知道的东西,所以也许这很明显以至于人们没有写任何东西。我不认为我在复制
目前的networkRuleSet
配置已经足够了。我无法使用与您相同的 networkRuleSet
配置重现此问题。因此,您可以在创建容器或查询 networkRuleSet
.
默认情况下,存储帐户接受来自任何网络上的客户端的连接。要限制对选定网络的访问,您必须先更改默认操作。
如果您只需要允许从某些特定 IP 地址或特定子网访问您的存储帐户并允许 Azure 服务,您可以这样添加,
{
"bypass": "AzureServices",
"defaultAction": "Deny",
"ipRules": [
{
"action": "Allow",
"ipAddressOrRange": "100.100.100.100"
}
],
"virtualNetworkRules": [
{
"action": "Allow",
"virtualNetworkResourceId": "subnetID"
}
]
}
使用 Azure CLI,将默认规则设置为默认允许网络访问。
az storage account update --resource-group "myresourcegroup" --name "mystorageaccount" --default-action Deny
az storage account update --resource-group "myresourcegroup" --name "mystorageaccount" --default-action Allow
有关详细信息,请参阅 Change the default network access rule。
编辑
在这种情况下,您设置 --auth-mode
参数以登录到 authorize with Azure AD credentials. You need to ensure that the Azure AD security principal with which you sign in to Azure CLI has permission to do data operations against Blob or Queue storage. For more information about RBAC roles in Azure Storage, see Manage access rights to Azure Storage data with RBAC。
不确定这是否有帮助...
如果您使用 CLI 更新存储帐户的“防火墙和虚拟网络”部分并使其可供所有网络访问,则需要一些时间才能生效。我观察到它需要大约 10 -30 秒才能生效。
尝试等待 30 秒,然后尝试 az container create 语句。它应该有效。
虽然选择的答案不同
可能还有其他原因,比如我的情况。如 Microsoft 文档 here
所述,您需要成为该角色才能创建容器Before you create the container, assign the Storage Blob Data Contributor role to yourself. Even though you are the account owner, you need explicit permissions to perform data operations against the storage account.
另请注意
Azure role assignments may take a few minutes to propagate.
从您的命令中删除 --auth-mode login
。像这样使用它:
az storage container create \
--account-name helloworld12345 \
--name images \
--public-access container
如果我们不设置--auth-mode
,它使用默认的授权模式key
。它将查询存储帐户中的帐户密钥
https://docs.microsoft.com/en-us/azure/storage/blobs/authorize-data-operations-cli
如果您在命令中需要 RBAC 角色,请使用 --auth-mode login
。有关存储中 RBAC 角色的更多信息,请访问 https://docs.microsoft.com/en-us/azure/storage/common/storage-auth-aad-rbac-cli。