覆盖 Blob 存储上的 Blob - 出现 "read only" 异常
Overwrite a blob on Blob Storage - getting "read only" exception
我想覆盖 Azure Blob 存储上的 blob myfile.txt
。我使用此代码,其中 blob_url
包含 SAS 令牌。该 blob 的访问级别为“私有”。
但是,我总是得到这个错误:
Result: Failure Exception: OSError: [Errno 30] Read-only file system: './TimerTrigger1/myfile.txt' Stack: File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/dispatcher.py", line 402, in _handle__invocation_request call_result = await self._loop.run_in_executor( File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run result = self.fn(*self.args, **self.kwargs) File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/dispatcher.py", line 606, in _run_sync_func return ExtensionManager.get_sync_invocation_wrapper(context, File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/extension.py", line 215, in _raw_invocation_wrapper result = function(**args) File "/home/site/wwwroot/TimerTrigger1/__init__.py", line 32, in main open(filename, 'wb').write(r.content)
这是我在 Python 中的代码:
blob_url = "https://me.blob.core.windows.net/mycontainer/myfile.txt?sp=r&st=2021-10-05T14:07:24Z&se=2021-10-05T22:07:24Z&spr=https&sv=2020-08-04&sr=b&sig=asdfasdfasdfa"
blob_client = BlobClient.from_blob_url(
blob_url=blob_url
)
with open("myfile.txt", "rb") as blob_file:
blob_client.upload_blob(data=blob_file)
关于如何做到这一点有什么想法吗?
这是因为您在 SAS 令牌 (sp=r
) 中只有 read
权限。为了更新 blob,您还需要在您的令牌中获得 write
权限。
请创建具有 read
和 write
权限的 SAS 令牌,您应该能够更新 blob。您的 SAS URL 应该类似于:
https://me.blob.core.windows.net/mycontainer/myfile.txt?sp=rw&st=2021-10-05T14:07:24Z&se=2021-10-05T22:07:24Z&spr=https&sv=2020-08-04&sr=b&sig=asdfasdfasdfa
我想覆盖 Azure Blob 存储上的 blob myfile.txt
。我使用此代码,其中 blob_url
包含 SAS 令牌。该 blob 的访问级别为“私有”。
但是,我总是得到这个错误:
Result: Failure Exception: OSError: [Errno 30] Read-only file system: './TimerTrigger1/myfile.txt' Stack: File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/dispatcher.py", line 402, in _handle__invocation_request call_result = await self._loop.run_in_executor( File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run result = self.fn(*self.args, **self.kwargs) File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/dispatcher.py", line 606, in _run_sync_func return ExtensionManager.get_sync_invocation_wrapper(context, File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/extension.py", line 215, in _raw_invocation_wrapper result = function(**args) File "/home/site/wwwroot/TimerTrigger1/__init__.py", line 32, in main open(filename, 'wb').write(r.content)
这是我在 Python 中的代码:
blob_url = "https://me.blob.core.windows.net/mycontainer/myfile.txt?sp=r&st=2021-10-05T14:07:24Z&se=2021-10-05T22:07:24Z&spr=https&sv=2020-08-04&sr=b&sig=asdfasdfasdfa"
blob_client = BlobClient.from_blob_url(
blob_url=blob_url
)
with open("myfile.txt", "rb") as blob_file:
blob_client.upload_blob(data=blob_file)
关于如何做到这一点有什么想法吗?
这是因为您在 SAS 令牌 (sp=r
) 中只有 read
权限。为了更新 blob,您还需要在您的令牌中获得 write
权限。
请创建具有 read
和 write
权限的 SAS 令牌,您应该能够更新 blob。您的 SAS URL 应该类似于:
https://me.blob.core.windows.net/mycontainer/myfile.txt?sp=rw&st=2021-10-05T14:07:24Z&se=2021-10-05T22:07:24Z&spr=https&sv=2020-08-04&sr=b&sig=asdfasdfasdfa