第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

Azure 函數(shù)“本地”文件

Azure 函數(shù)“本地”文件

紅糖糍粑 2023-06-27 17:51:14
我正在 Python 中創(chuàng)建一個(gè) HTTP 函數(shù),它將從存儲(chǔ)中獲取 csv blob,使用 scipy 和 matplotlib 執(zhí)行一些操作,并使用 wkhtmltopdf 將 pdf 輸出到同一容器。我在本地系統(tǒng)上執(zhí)行任何此操作都沒有問題,但像大多數(shù)事情一樣,當(dāng)我部署它時(shí)它會(huì)停止工作。該函數(shù)需要覆蓋 pickle 文件(在 blob 存儲(chǔ)中),創(chuàng)建多個(gè)圖像 (.png) 和 html 文件,并引用 wkhtmltopdf 的 exe 將這些 png 和 html 轉(zhuǎn)換為 pdf。pickle 部分首先出現(xiàn),并在此行上捕獲此錯(cuò)誤所以看起來(lái)我無(wú)法寫入當(dāng)前目錄,這將證明是圖像的問題。這是處理這種情況的錯(cuò)誤方法嗎?有人可以問我正確的問題來(lái)縮小問題的根源嗎?下面是我的代碼的一個(gè)子集:sas_token_output_html = generate_blob_sas(account_name='***',                            account_key='***',                            container_name=container,                            blob_name='output.html',                            permission=BlobSasPermissions(read=True, write=True, create=True),                            expiry=datetime.datetime.utcnow() + datetime.timedelta(hours=1))output_html_url =f'https://***.blob.core.windows.net/{container}/output.html?{sas_token_output_html}'template_vars = {        'week_day':'Wednesday',        'month':datetime.date.today().strftime('%B'),        'day': datetime.date.today().day,        'year': datetime.date.today().year,        ...}        message_html = template.render(template_vars)with open('output_html_url','w') as f:    f.write(message_html)
查看完整描述

2 回答

?
富國(guó)滬深

TA貢獻(xiàn)1790條經(jīng)驗(yàn) 獲得超9個(gè)贊

我無(wú)法在本地存儲(chǔ)任何內(nèi)容,但我能夠?qū)⑽业膸椭绦蛭募?函數(shù)存儲(chǔ)在存儲(chǔ) blob 中,并使用以下命令在本地下載 blob:

with open(os.path.join(tempfile.gettempdir(), 'input.csv'), 'wb') as input:
        input.write(blob_client.download_blob().readall())

這并不能解決具體問題,但它是一個(gè)可以接受的解決方法。


查看完整回答
反對(duì) 回復(fù) 2023-06-27
?
一只甜甜圈

TA貢獻(xiàn)1836條經(jīng)驗(yàn) 獲得超5個(gè)贊

我看到這個(gè)片段希望能完成類似的事情。我把與我無(wú)關(guān)的部分都拿出來(lái)了。這可以在 vscode 中使用函數(shù)應(yīng)用程序的測(cè)試功能時(shí)創(chuàng)建一個(gè)文件(func start):(來(lái)自https://option40.com/blog/azure)


import logging

import tempfile

import azure.functions as func



def main(req: func.HttpRequest) -> func.HttpResponse:

    logging.info('Python HTTP trigger function processed a request.')


    dir_path = tempfile.gettempdir()

    file = dir_path + "\test.txt"

    name = "Me"


    with open(file, mode="w") as f:

        f.write(f"{name}")

        

    with open(file) as f:

        new = f.read()


    if name:

        return func.HttpResponse(f"{file}, {new}")

    else:

        return func.HttpResponse(

             "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.",

             status_code=200

        )

我的結(jié)果:C:\Users\myName\AppData\Local\Temp\test.txt,Me


查看完整回答
反對(duì) 回復(fù) 2023-06-27
  • 2 回答
  • 0 關(guān)注
  • 169 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)