有人能告诉我是否可以直接从Azure blob存储中读取csv文件作为流并使用Python处理它?我知道它可以使用C#.Net(如下所示)完成,但想知道Python中的等效库来执行此操作.
CloudBlobClient client = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = client.GetContainerReference("outfiles");
CloudBlob blob = container.GetBlobReference("Test.csv");*
Run Code Online (Sandbox Code Playgroud) 我有一个正在使用azure.storage.blob python模块的应用程序。
显然,当我执行它时,该模块会将其日志数据转储到我不想要的记录器中,因为它很大,并且我自己的应用程序信息在它们之间丢失了。
有什么方法可以从azure.storage.blob python模块中删除记录器?
日志样本:
INFO:azure.storage.common.storageclient:Client-Request-ID = d5afebc0-aa84-11e8-be16-000d3ae070ae传出请求:Method = PUT,Path = / marketingcloud-raw-events / 2018/8/27 / bounce.csv ,Query = {'timeout':None},Headers = {'Content-Length':'38176','x-ms-blob-type':'BlockBlob','x-ms-version':'2018-03 -28','x-ms-lease-id':无,'x-ms-client-request-id':'d5afebc0-aa84-11e8-be16-000d3ae070ae','If-Match':无,'If -Modified-Since':无,'If-None-Match':无,'User-Agent':'Azure-Storage / 1.3.0-1.3.1(Python CPython 2.7.15; Linux 4.15.0-1021-天青)'
知道为什么当我使用 REST API 在 Cosmos DB 中执行下面的查询时出现下面的错误吗?没有 order by 的相同查询工作正常......
我在这两种情况下都设置了标头"x-ms-documentdb-query-enablecrosspartition: True",并且使用 PHP 来发出请求。
有效的多分区查询:
从 c 中选择 c.id、c.name、c.age,其中 c.age = 30
多分区查询有错误:
SELECT c.id, c.name, c.age FROM c where c.age = 30 order by c.age asc
错误:
客户端错误:
POST https://yeapp-cosmosdb.documents.azure.com//dbs/-JJZAA==/colls/-JJZAL+WPKw=/docs导致
400 BadRequest响应:{“code”:“BadRequest”,“message”:“网关无法直接提供所提供的跨分区查询。这是一个(截断的...)
您好,我正在尝试从 azure 数据工厂中的 Json 数组中选择状态
{
"dataRead": 2997,
"dataWritten": 2714,
"filesWritten": 1,
"sourcePeakConnections": 1,
"sinkPeakConnections": 1,
"rowsRead": 11,
"rowsCopied": 11,
"copyDuration": 3,
"throughput": 0.976,
"errors": [],
"effectiveIntegrationRuntime": "DefaultIntegrationRuntime (East US)",
"usedDataIntegrationUnits": 4,
"billingReference": {
"activityType": "DataMovement",
"billableDuration": [
{
"meterType": "AzureIR",
"duration": 0.06666666666666667,
"unit": "DIUHours"
}
]
},
"usedParallelCopies": 1,
"executionDetails": [
{
"source": {
"type": "AzureSqlDatabase",
"region": "East US"
},
"sink": {
"type": "AzureBlobStorage",
"region": "East US"
},
"status": "Succeeded",
"start": "2020-03-19T06:24:39.0666585Z",
"duration": 3,
"usedDataIntegrationUnits": 4,
"usedParallelCopies": 1,
Run Code Online (Sandbox Code Playgroud)
我尝试过选择。 …
我在C#中有一个VS2017解决方案,我正在使用IDocumentClient.UpsertDocumentAsync将一些文档嵌入到我的cosmosdb documentdb集合中.但是我注意到它实际上创建了具有相同id的新文档,而集合中已经存在具有该id的文档.
现在,在插入具有相同id的新文档之后,查询结果如下所示:
select * from c where c.id = "aaaa-bbbb-cccc"
[
{
"id": "aaaa-bbbb-cccc",
"firstname": "john",
"lastname": "doe"
},
{
"id": "aaaa-bbbb-cccc",
"firstname": "john",
"lastname": "doe",
"age": "35"
}
]
Run Code Online (Sandbox Code Playgroud)
我对这种行为很困惑; 也许我没有正确理解"upsert"的定义.如果有人能为我澄清这一点,我将不胜感激.
我将 REST API 与 SQL for Cosmos db 结合使用,需要返回按时间戳(存储为 UNIX 数字时间戳)排序的查询结果。我正在尝试用一个简单的 ORDER BY 来做到这一点。
e.g. SELECT * FROM requests c ORDER BY c.timestamp
Run Code Online (Sandbox Code Playgroud)
但是,通过分区,我收到错误:
“不支持使用 TOP/ORDER BY 或聚合函数进行跨分区查询。”
在集合设置中,字符串的索引精度设置为 -1,这是其他地方的建议,但仍然会引发错误。
如果我删除 x-ms-documentdb-query-enablecrosspartition 标头或将其设置为 false,则会得到:
“跨分区查询是必需的,但已禁用。请将 x-ms-documentdb-query-enablecrosspartition 设置为 true,指定 x-ms-documentdb-partitionkey,或修改查询以避免此异常。”
有没有人通过 SQL REST API 成功做到这一点?
谢谢。
编辑:我希望Azure Storage Container通过BLOB-specific SAS.
from azure.storage.blob import BlobService
sas_service = BlobService(
account_name = "name",
sas_token = "mytoken"
)
blob_content = sas_service.get_blob_to_path("container_name", "blob_name")
Run Code Online (Sandbox Code Playgroud)
我尝试使用它,但它输出的OSError列表也是“503 错误”
我在为简单的获取数据库请求生成 cosmos db 的授权令牌时遇到问题。这是我的Python代码:
import requests
import hmac
import hashlib
import base64
from datetime import datetime
key = 'AG . . .EZPcZBKz7gvrKiXKsuaPA=='
now = datetime.utcnow().strftime('%a, %d %b %Y %H:%M:00 GMT')
payload = ('get\ndbs\n\n' + now + '\n\n').lower()
signature = base64.b64encode(hmac.new(key, msg = payload, digestmod = hashlib.sha256).digest()).decode()
url = 'https://myacct.documents.azure.com/dbs'
headers = {
'Authorization': "type=master&ver=1.0&sig=" + signature,
"x-ms-date": now,
"x-ms-version": "2017-02-22"
}
res = requests.get(url, headers = headers)
print res.content
Run Code Online (Sandbox Code Playgroud)
这会产生此错误:
{"code":"Unauthorized","message":"The input authorization token can't serve the request. Please check …Run Code Online (Sandbox Code Playgroud)