英文:
Accessing Blob content from within ARM Template for API Management API GraphQL Schema
问题
The GraphQL schema content is large so would like to store in blob container and access it from API Management ARM Template to obtain its contents.
我想将GraphQL模式内容存储在Blob容器中,并从API管理ARM模板中访问它以获取其内容。
I already store linked templates in same area and have enough detail to compose the URI with SAS Token .
我已经在相同的区域存储了链接的模板,并且有足够的详细信息来使用SAS令牌构建URI。
The issue I have is getting the contents from the blob and loading them into a string variable. Whatever I try I cannot access the contents.
我遇到的问题是从Blob获取内容并将其加载到字符串变量中。无论我尝试什么,都无法访问内容。
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"contentVersion": "1.0.0.0",
"parameters": {
"parameters": {
"ApimServiceName": {
"ApimServiceName": {
"type": "string"
"type": "string"
},
"appInsightsName": {
"appInsightsName": {
"type": "string"
"type": "string"
},
"_artifactsLocation" : {
"_artifactsLocation" : {
"type": "string"
"type": "string"
},
"_artifactsLocationSasToken" :{
"_artifactsLocationSasToken" :{
"type": "string"
"type": "string"
},
"_buildNumber" :{
"_buildNumber" :{
"type": "string"
"type": "string"
},
"KeyvaultName": {
"KeyvaultName": {
"type": "string"
"type": "string"
}
},
"variables": {
"variables": {
"linkedSchemas": {
"linkedSchemas": {
"schemauri": "[concat(parameters('ApimServiceName'), '/graphql-sample/graphql',parameters('_artifactsLocationSasToken'))]"
"schemauri": "[concat(parameters('ApimServiceName'), '/graphql-sample/graphql',parameters('_artifactsLocationSasToken'))]"
}
},
"resources": [
"resources": [
{
"apiVersion": "2021-08-01",
"apiVersion": "2021-08-01",
"type": "Microsoft.ApiManagement/service/apis",
"type": "Microsoft.ApiManagement/service/apis",
"name": "[concat(parameters('ApimServiceName'), '/graphql-sample')]",
"name": "[concat(parameters('ApimServiceName'), '/graphql-sample')]",
"dependsOn": [],
"dependsOn": [],
"properties": {
"properties": {
"description": "",
"description": "",
"authenticationSettings": {
"authenticationSettings": {
"subscriptionKeyRequired": false
"subscriptionKeyRequired": false
},
"subscriptionKeyParameterNames": {
"subscriptionKeyParameterNames": {
"header": "Ocp-Apim-Subscription-Key",
"header": "Ocp-Apim-Subscription-Key",
"query": "subscription-key"
"query": "subscription-key"
},
"type": "graphql",
"type": "graphql",
"apiRevision": "1",
"apiRevision": "1",
"subscriptionRequired": true,
"subscriptionRequired": true,
"displayName": "GraphQL API",
"displayName": "GraphQL API",
"serviceUrl": "https://emea.sample.com/api/graphql",
"serviceUrl": "https://emea.sample.com/api/graphql",
"path": "graphql-sample",
"path": "graphql-sample",
"protocols": [
"protocols": [
"http",
"http",
"https"
"https"
]
}
}
},
{
"apiVersion": "2021-08-01",
"apiVersion": "2021-08-01",
"type": "Microsoft.ApiManagement/service/apis/schemas",
"type": "Microsoft.ApiManagement/service/apis/schemas",
"name": "[concat(parameters('ApimServiceName'), '/graphql-sample/graphql')]",
"name": "[concat(parameters('ApimServiceName'), '/graphql-sample/graphql')]",
"dependsOn": [
"dependsOn": [
"resourceId('Microsoft.ApiManagement/service/apis', parameters('ApimServiceName'), 'graphql-sample')]"
"resourceId('Microsoft.ApiManagement/service/apis', parameters('ApimServiceName'), 'graphql-sample')]"
],
"properties": {
"properties": {
"contentType": "application/vnd.ms-azure-apim.graphql.schema",
"contentType": "application/vnd.ms-azure-apim.graphql.schema",
"document": {
"document": {
"value": "[concat('data:text/plain;charset=utf-8;base64,', base64(variables('linkedSchemas').schemauri))]"
"value": "[concat('data:text/plain;charset=utf-8;base64,', base64(variables('linkedSchemas').schemauri))]"
}
}
}
}, etc...
}, etc...
Can anyone share how to obtain the contents of the blob? Perhaps I need to find a different way to access the blob. All the code does as it stands is turn the URI itself into base64.
有人可以分享如何获取Blob的内容吗?也许我需要找到不同的方法来访问Blob。目前所有代码所做的就是将URI本身转换为base64。
英文:
The GraphQL schema content is large so would like to store in blob container and access it from API Management ARM Template to obtain its contents.
I already store linked templates in same area and have enough detail to compose the URI with SAS Token .
The issue I have is getting the contents from the blob and loading them into a string variable. Whatever I try I cannot access the contents.
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"ApimServiceName": {
"type": "string"
},
"appInsightsName": {
"type": "string"
},
"_artifactsLocation" : {
"type": "string"
},
"_artifactsLocationSasToken" :{
"type": "string"
},
"_buildNumber" :{
"type": "string"
},
"KeyvaultName": {
"type": "string"
}
},
"variables": {
"linkedSchemas": {
"schemauri": "[concat(parameters('_artifactsLocation'), parameters('_buildNumber'), '/sample-graphql-schema.graphql',parameters('_artifactsLocationSasToken'))]"
}
},
"resources": [
{
"apiVersion": "2021-08-01",
"type": "Microsoft.ApiManagement/service/apis",
"name": "[concat(parameters('ApimServiceName'), '/graphql-sample')]",
"dependsOn": [],
"properties": {
"description": "",
"authenticationSettings": {
"subscriptionKeyRequired": false
},
"subscriptionKeyParameterNames": {
"header": "Ocp-Apim-Subscription-Key",
"query": "subscription-key"
},
"type": "graphql",
"apiRevision": "1",
"subscriptionRequired": true,
"displayName": "GraphQL API",
"serviceUrl": "https://emea.sample.com/api/graphql",
"path": "graphql-sample",
"protocols": [
"http",
"https"
]
}
},
{
"apiVersion": "2021-08-01",
"type": "Microsoft.ApiManagement/service/apis/schemas",
"name": "[concat(parameters('ApimServiceName'), '/graphql-sample/graphql')]",
"dependsOn": [
"[resourceId('Microsoft.ApiManagement/service/apis', parameters('ApimServiceName'), 'graphql-sample')]"
],
"properties": {
"contentType": "application/vnd.ms-azure-apim.graphql.schema",
"document": {
"value": "[concat('data:text/plain;charset=utf-8;base64,', base64(variables('linkedSchemas').schemauri))]"
}
}
}, etc...
Can anyone share how to obtain the contents of the blob? Perhaps I need to find a different way to access the blob. All the code does as it stands is turn the URI itself into base64.
答案1
得分: 1
ARM Templates 本身据我所知不支持从 URL 获取值。但是,APIM 模板支持传递值,该服务可以获取内容。
为此,您不需要 Microsoft.ApiManagement/service/apis/schemas
子资源,而是需要设置 Microsoft.ApiManagement/service/apis
资源本身的属性。
format
应设置为graphql-link
value
应设置为包括 SAS 令牌的 GraphQL 模式文件的 URL
请参考 参考文档 以获取更多信息。
英文:
ARM Templates on their own do does not support fetching values from a URL as far as I know. But APIM Templates do support passing in values, which the service can fetch contents for.
For this, you don't need the Microsoft.ApiManagement/service/apis/schemas
sub-resource, instead the Microsoft.ApiManagement/service/apis
resource itself has properties that you need to set.
format
should be set tographql-link
value
should be set to the URL of your GraphQL Schema File including the SAS Token
Refer the reference doc for more information.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论