Azure存储-如何以编程方式获取静态网站URL



我已经在Azure存储帐户上启用了静态网站。

我们使用主服务URL(mycontainer.blob.core.windows.net(上传文件,并使用静态网站URL(mycontainer.z6.web.core.windows.net(提供这些文件。

该应用程序具有用于上载的容器的连接字符串。但我需要知道结果的公共静态网站URL将是什么。

有没有任何方法可以使用REST API从我的应用程序中以编程方式检索静态网站URL?(我知道我可以用PowerShell或Azure Portal来完成,这不是我在这里需要的。(

该应用程序托管在几个不同的环境中,我不想为主要端点和web端点都有单独的应用程序配置参数。我应该能够有一个单一的真理来源。

我使用的是Node SDK(@azure/storage-blob(。我看到有一种方法可以使用@azure/arm-storage来实现这一点,但这需要不同的身份验证方法,所以不太好。

我甚至准备自己把它缝合在一起,但我需要一种方法来弄清楚z6(在这个例子中(将是什么

由于存储帐户REST API,您可以检索web端点:https://learn.microsoft.com/en-us/rest/api/storagerp/storage-accounts/get-properties#storageaccountgetproperties

响应示例:

{
"id": "/subscriptions/{subscription-id}/resourceGroups/res9407/providers/Microsoft.Storage/storageAccounts/sto8596",
"kind": "Storage",
"location": "eastus2(stage)",
"name": "sto8596",
"properties": {
"keyCreationTime": {
"key1": "2021-03-18T04:42:22.4322836Z",
"key2": "2021-03-18T04:42:22.4322836Z"
},
"geoReplicationStats": {
"status": "Live",
"lastSyncTime": "2018-10-30T00:25:34Z",
"canFailover": true
},
"isHnsEnabled": true,
"creationTime": "2017-06-01T02:42:41.7633306Z",
"networkAcls": {
"bypass": "AzureServices",
"defaultAction": "Allow",
"ipRules": [],
"virtualNetworkRules": [],
"resourceAccessRules": [
{
"tenantId": "72f988bf-86f1-41af-91ab-2d7cd011db47",
"resourceId": "/subscriptions/a7e99807-abbf-4642-bdec-2c809a96a8bc/resourceGroups/res9407/providers/Microsoft.Synapse/workspaces/testworkspace"
}
]
},
"primaryEndpoints": {
"web": "https://sto8596.web.core.windows.net/",
"dfs": "https://sto8596.dfs.core.windows.net/",
"blob": "https://sto8596.blob.core.windows.net/",
"file": "https://sto8596.file.core.windows.net/",
"queue": "https://sto8596.queue.core.windows.net/",
"table": "https://sto8596.table.core.windows.net/",
"microsoftEndpoints": {
"web": "https://sto8596-microsoftrouting.web.core.windows.net/",
"dfs": "https://sto8596-microsoftrouting.dfs.core.windows.net/",
"blob": "https://sto8596-microsoftrouting.blob.core.windows.net/",
"file": "https://sto8596-microsoftrouting.file.core.windows.net/",
"queue": "https://sto8596-microsoftrouting.queue.core.windows.net/",
"table": "https://sto8596-microsoftrouting.table.core.windows.net/"
},
"internetEndpoints": {
"web": "https://sto8596-internetrouting.web.core.windows.net/",
"dfs": "https://sto8596-internetrouting.dfs.core.windows.net/",
"blob": "https://sto8596-internetrouting.blob.core.windows.net/",
"file": "https://sto8596-internetrouting.file.core.windows.net/"
}
},
"primaryLocation": "eastus2(stage)",
"provisioningState": "Succeeded",
"routingPreference": {
"routingChoice": "MicrosoftRouting",
"publishMicrosoftEndpoints": true,
"publishInternetEndpoints": true
},
"encryption": {
"services": {
"file": {
"keyType": "Account",
"enabled": true,
"lastEnabledTime": "2019-12-11T20:49:31.7036140Z"
},
"blob": {
"keyType": "Account",
"enabled": true,
"lastEnabledTime": "2019-12-11T20:49:31.7036140Z"
}
},
"keySource": "Microsoft.Storage"
},
"secondaryLocation": "northcentralus(stage)",
"statusOfPrimary": "available",
"statusOfSecondary": "available",
"supportsHttpsTrafficOnly": false
},
"sku": {
"name": "Standard_GRS",
"tier": "Standard"
},
"tags": {
"key1": "value1",
"key2": "value2"
},
"type": "Microsoft.Storage/storageAccounts"
}

您可以使用以下json路径找到url:primaryEndpoints.web

相关内容

  • 没有找到相关文章

最新更新