我正在开发一个使用 Azure 数据工厂和 Blob 存储的项目。我有一个需求,但不知道如何实现。
要求:
#1 检查 blob 存储容器是否存在。 #2 通过 power shell 脚本在数据工厂中创建新容器。基本上,容器只会在管道第一次运行时创建。 #3 调用API。
#1==> 我找到了检查 if blob exists, 的方法但没有找到容器。
#2==> 通过 Power shell 脚本从 Azure 数据工厂创建容器的最佳方法是什么:通过批处理?还是通过函数来完成更好?
非常感谢您提前提供的帮助
最佳答案
作为post也就是说,我们可以使用 GetMetadata 事件和 If Condition 事件来检查 blob 是否存在。如果blob不存在,我们可以使用Azure函数创建容器并通过http get请求指定容器的名称。我觉得使用Azure功能更方便。
例如,这里我在Azure函数中使用nodejs。根据 Azure function javascript和 Manage blobs with JavaScript v12 SDK in Node.js 。我们可以开始一个项目。
然后修改一些代码index.js,以便我们可以管理blob容器(创建一个容器)。
const { BlobServiceClient } = require('@azure/storage-blob');
module.exports = async function (context, req) {
const AZURE_STORAGE_CONNECTION_STRING = "<your_connect_string>";
const blobServiceClient = BlobServiceClient.fromConnectionString(AZURE_STORAGE_CONNECTION_STRING);
const name = (req.query.name || (req.body && req.body.name));
const containerClient = blobServiceClient.getContainerClient(name);
// Create the container
const createContainerResponse = await containerClient.create();
const responseMessage = name
? "Container:" + name + " has been created!"
: "...";
context.res = {
// status: 200, /* Defaults to 200 */
body: responseMessage
};
}
关于azure - 通过Azure数据工厂创建blob存储容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65190284/