获取用于使用链接模板进行ARM部署的blob存储容器的SAS令牌

问题描述 投票:0回答:1

我想做的是在本地系统上使用Azure CLI部署ARM模板,因为我想先在本地尝试更改,然后再将其推送到存储库。

我们正在使用链接模板,这意味着我必须指定链接模板所在的URL和SAS令牌才能访问这些文件。

我正在尝试执行的脚本如下所示

az group deployment create --resource-group myResourceGroupName `
            --template-file azuredeploy.json `
            --parameters azuredeploy.d.parameters.json `
            --parameters local.parameters.json

azuredeploy.json文件包含主模板,以及对其他链接模板的引用。azuredeploy.d.parameters.json文件包含所有常规环境参数(如定价层等)。local.parameters.json包含2个称为deploymentContainerSasTokendeploymentContainerUri的参数(SAS令牌和链接模板的位置)。

我正在创建SAS令牌的操作如下。

$end=date -u -d "30 minutes" '+%Y-%m-%dT%H:%MZ'
$start=date '+%Y-%m-%dT00:00Z'

az storage container generate-sas `
            --account-name "mydeploymentfiles" `
            --account-key "[thePrimaryKey]" `
            --name "the/subfolder/buildversion.1+52/templates" `
            --start $start `
            --expiry $end `
            --permissions lr `
            --output tsv

这将输出一个我可以使用的不错的SAS令牌。

st = 2019-11-18T00%3A00Z&se = 2019-11-18T14%3A30Z&sp = rl&sv = 2018-03-28&sr = c&sig = aZn3cx%2BNCnN2YhXD9%2AeTJa6TQL / pUIpbsbP4HKtFN / 4%3D

通过Azure CLI运行部署时,我收到消息,指示无法访问链接的模板(the/subfolder/buildversion.1+52/templates/function-app.jsonthe/subfolder/buildversion.1+52/templates/storage.json)。

因此,我尝试使用生成的SAS令牌从浏览器下载它们,并得到以下内容。

<?xml version="1.0" encoding="utf-8"?>
<Error>
    <Code>AuthenticationFailed</Code>
    <Message>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly
        including the signature.
        RequestId:2c0412dc-201e-0038-6b97-9e01ef000000
        Time:2019-11-19T05:11:12.2088927Z</Message>
    <AuthenticationErrorDetail>Signature not valid in the specified time frame: Start [Mon, 18 Nov 2019 00:00:00 GMT] -
        Expiry [Mon, 18 Nov 2019 14:30:00 GMT] - Current [Tue, 19 Nov 2019 05:11:12 GMT]</AuthenticationErrorDetail>
</Error>

思考这是要做的事情,因为我正在为文件所在的容器创建SAS令牌,但是具有ListRead权限,我应该可以访问它,对吧?] >

发布管道运行正常,我在那儿使用Azure Blob文件副本来设置适当的参数。

Release pipeline steps

我现在有点迷路了。

从本地系统运行时,要使工作的SAS令牌用于链接的模板的正确方法是什么,链接的模板位于某些子容器中。]

我正在尝试在本地系统上使用Azure CLI部署ARM模板,因为我想先在本地尝试更改,然后再将其推送到存储库。我们正在使用链接的...

azure azure-storage azure-resource-manager arm-template azure-cli
1个回答
1
投票

根据您提供的信息,您要为Azure Blob存储容器中的文件夹生成SAS令牌。是不可能的。因为Azure Blob存储不具有“文件夹”概念。有关更多详细信息,请参阅documentarticleenter image description here

因此,请为包含您需要访问的Blob或您要访问的每个Blob的容器生成SAS令牌。例如

© www.soinside.com 2019 - 2024. All rights reserved.