英文:
How can I use Azure Storage Account with Keystone?
问题
我有一个需要迁移到Azure订阅的应用程序。技术栈包括NextJs、Prisma和Keystone。
它涉及一些文件上传操作,而Keystone内置支持S3存储。
是否有办法在S3的位置上使用Azure存储账户?
我尝试过使用https://www.npmjs.com/package/@k6-contrib/fields-azure,但无法使其工作。
英文:
I have an app that I need to move to an Azure subcription. the stack is NextJs, Prisma and Keystone.
It is doing some file uploading and Keystone have built in support for s3 storage.
Is there a way to use a Azure Storage account in place of an s3?
I tried using this https://www.npmjs.com/package/@k6-contrib/fields-azure but can't get it to work.
答案1
得分: 1
我得到了来自另一个来源的帮助,并成功解决了它。
我使用了这个包(https://www.npmjs.com/package/@k6-contrib/fields-azure),但不得不进行一些修改。
在 keystone.ts
中
添加导入
import {AzureStorageConfig, azureStorageImage} from "@k6-contrib/fields-azure";
然后需要为SA连接创建一个配置对象。
const azConfig: AzureStorageConfig = {
azureStorageOptions: {
account: process.env.AZURE_STORAGE_ACCOUNT_NAME || '',
accessKey: process.env.AZURE_STORAGE_ACCESS_KEY || '',
container: process.env.AZURE_STORAGE_CONTAINER || '',
url: process.env.AZURE_STORAGE_ACCOUNT_HOST
? `${process.env.AZURE_STORAGE_ACCOUNT_HOST}${process.env.AZURE_STORAGE_CONTAINER}`
: undefined,
},
};
请注意,这与npm和示例中的说明略有不同。url 需要是 "host/container"。
然后需要设置与存储连接的字段。在我的情况下是 "logo" 字段。
logo: azureStorageImage({azureStorageConfig: azConfig})
AZURE_STORAGE_CONTAINER
- 存储帐户中容器的名称。
AZURE_STORAGE_ACCOUNT_NAME
- 存储帐户的名称。
AZURE_STORAGE_ACCESS_KEY
- 存储帐户的访问密钥。
AZURE_STORAGE_ACCOUNT_HOST
- 存储帐户的 URL/终端点。
希望这能帮助有类似问题的其他人。
英文:
I got help from another source and managed to solve it.
I used the package (https://www.npmjs.com/package/@k6-contrib/fields-azure) but had to make some modifications.
In keystone.ts
Add import
import {AzureStorageConfig, azureStorageImage} from "@k6-contrib/fields-azure";
Then a config object needs to be created for the SA-connection.
const azConfig: AzureStorageConfig = {
azureStorageOptions: {
account: process.env.AZURE_STORAGE_ACCOUNT_NAME || '',
accessKey: process.env.AZURE_STORAGE_ACCESS_KEY || '',
container: process.env.AZURE_STORAGE_CONTAINER || '',
url: process.env.AZURE_STORAGE_ACCOUNT_HOST
? `${process.env.AZURE_STORAGE_ACCOUNT_HOST}${process.env.AZURE_STORAGE_CONTAINER}`
: undefined,
},
};
Note that this differs somewhat from the instructions at npm and in the example. The url needed to be "host/container".
Then the fields connected to the storage needed to be set. In my case the "logo" field.
logo: azureStorageImage({azureStorageConfig: azConfig})
AZURE_STORAGE_CONTAINER
- The name of the container in the storage account.
AZURE_STORAGE_ACCOUNT_NAME
- The name of the storage account.
AZURE_STORAGE_ACCESS_KEY
- The access key for the storage account.
AZURE_STORAGE_ACCOUNT_HOST
- The url/endpoint to the storage account.
Hope this can help someone out there with a similar problem.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论