在Azure中使用时间戳访问Blob文件 [英] Access blob file using time stamp in Azure

查看:140
本文介绍了在Azure中使用时间戳访问Blob文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想访问从azure ml Web服务中生成的Blob文件以及ilearner和csv文件.问题在于该文件是使用guid作为名称自动生成的,并且没有响应提及该文件的存在.我知道该文件正在生成,因为我可以通过azure门户对其进行访问.我想自动访问该文件,并且我看到的唯一可能性是使用在同一实例中创建的其他文件的时间戳.是否有任何API或方法可用于使用时间戳而不是文件名来访问在特定实例中创建的Blob?

I want to access a blob file that is getting generated out of azure ml web service along with the ilearner and csv file. The problem is that the file is getting generated automatically with guid as its name, and with no response mentioning the existence of that file. I know that the file is getting generated as i can access it through azure portal. i would like to automatically access the file and the only possibility i can see is by using the time stamp of other file created at the same instance. is there any api or method available to access blobs created at a particular instance using time stamp instead of file name?

推荐答案

根据您的描述,我猜您使用了导出数据模块". 根据您的要求,强烈建议您使用Azure机器学习中的执行Python脚本替换导出数据,从而可以自定义Blob文件名.

According to your description, I guess you used Export Data Module. As your requirements, it is highly recommended that you could replace Export Data with Execute Python Script in Azure Machine Learning which allows you to customize the blob file name.

有关执行Python脚本的介绍,您可以参考官方文档

For the introduction to Execute Python Script, you could refer to the official documentation here.

请参考以下步骤实施:

步骤1 :请使用Python virtualenv 创建独立于Python的运行环境,具体步骤请参考

Step 1: Please use Python virtualenv create Python independent running environment, specific steps please refer to https://virtualenv.pypa.io/en/stable/userguide/, then use the pip install command to download Azure Storage related Scripts.

Lib/site-packages 文件夹中的所有文件压缩到一个zip包中(我称它为azure-存储-此处的包)

Compress all of the files in the Lib/site-packages folder into a zip package (I'm calling it azure - storage - package here)

步骤2 :将zip程序包上传到Azure机器学习WorkSpace数据集.

Step 2: Upload the zip package into the Azure Machine Learning WorkSpace DataSet.

特定步骤,请参考技术说明.

成功后,您将在数据集列表"中看到上载的软件包,并将其拖到执行Python脚本"的第三个节点.

After success, you will see the uploaded package in the DataSet List, dragging it to the third node of the Execute Python Script.

第3步 :在时间戳中自定义python脚本中的blob文件名,甚至可以添加GUID以确保文件名末尾的唯一性. 我提供了一个简单的代码段:

Step 3 : Customize the blob file name in the python script to the timestamp, you could even add GUID to ensure uniqueness at the end of the file name. I provided a simple snippet of code:

import pandas as pd
from azure.storage.blob import BlockBlobService
import time


def azureml_main(dataframe1 = None, dataframe2 = None):
    myaccount= '****'
    mykey= '****'

    block_blob_service = BlockBlobService(account_name=myaccount, account_key=mykey)

    block_blob_service.create_blob_from_text('test', 'str(int(time.time()))+'.txt', 'upload image test')

    return dataframe1,

此外,您可以参考SO线程从Azure ML实验中访问Azure博客存储.

Also,you could refer to the SO thread Access Azure blog storage from within an Azure ML experiment.

希望它对您有帮助.

这篇关于在Azure中使用时间戳访问Blob文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆