我有一个 Person 类,并将其保存到 Azure 表存储中的表中。
我想使用以下查询之一来查询它:
var query = from getThis in _serviceContext.CreateQuery<PersonForSearch>(_tableName)
where getThis.Name.Contains(searchTerm)
select new Person
{
PartitionKey = getThis.PartitionKey,
RowKey = getThis.RowKey,
Name = getThis.Name
};
Run Code Online (Sandbox Code Playgroud)
或者
CloudTableQuery<Person> query =
(from getThis in _serviceContext.CreateQuery<Person>(_tableName)
where getThis.Name.Contains(searchTerm)
select getThis).AsTableServiceQuery<Person>();
Run Code Online (Sandbox Code Playgroud)
无论使用哪一种,我都会收到以下错误,该错误出现在我用来循环查询结果的 foreach 循环上:
NotImplemented
未在指定资源上执行请求的操作。
我认为这可能是因为我的 Person 模型不是从 TableServiceEntity 继承的(我拒绝引入这种耦合 - 所以我用这个属性装饰它: [DataServiceKey("PartitionKey", "RowKey")] 并手动给出它是 PartitionKey 和 RowKey 属性。
因此,我尝试创建一个 DID 继承自 TableServiceEntity 的实体,这将允许我查询该表(正如您从查询中看到的,我唯一担心的属性是 Name)。
这个新实体如下:
class PersonForSearch : TableServiceEntity
{
public string Name { get; set; }
} …Run Code Online (Sandbox Code Playgroud) 假设我有一个包含 50K 行的 Azure 存储表,其中包含这样的实体
{
PartitionKey,
RowKey,
Name,
Price
}
Run Code Online (Sandbox Code Playgroud)
查询会是这样的
var query = from entity in dataServiceContext.CreateQuery<MyEntity>(tableName)
where entity.Price == 10
select new { entity.Name};
Run Code Online (Sandbox Code Playgroud)
当我需要搜索 Price == 10 的所有实体时,交易是否仅根据返回的结果数进行计数?或者每个实体 (entity.Price == 10) 的检查是否会被计为单独的读取事务,这会导致 50K 事务?
我正在尝试获取 Microsoft Azure 存储上所有表的列表。如果我知道表的名称,我就能够成功连接并从表中读取行。有一种方法可以获取具有以下定义的表列表:
public virtual IEnumerable<CloudTable> ListTables(string prefix = null, TableRequestOptions requestOptions = null, OperationContext operationContext = null);
Run Code Online (Sandbox Code Playgroud)
现在我的问题是,如果我不传递任何参数,我是否会期望获得所有表的列表。我也尝试传递“*”作为前缀,但这似乎也没有给我带来任何结果。
这是我的代码:
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
IEnumerable<CloudTable> tableList = tableClient.ListTables("*");//returns empty list
IEnumerable<CloudTable> tableList = tableClient.ListTables();//returns empty list
Run Code Online (Sandbox Code Playgroud) 这是我配置Azure存储帐户的代码
public CloudTableClient ConfigureStorageAccount()
{
var storageCred = new StorageCredentials(ConfigurationManager.AppSettings["SASToken"]);
CloudTableClient = new CloudTableClient(
new StorageUri(new Uri(ConfigurationManager.AppSettings["StorageAccountUri"])), storageCred);
var backgroundRequestOption = new TableRequestOptions()
{
// Client has a default exponential retry policy with 4 sec delay and 3 retry attempts
// Retry delays will be approximately 3 sec, 7 sec, and 15 sec
MaximumExecutionTime = TimeSpan.FromSeconds(30),
// PrimaryThenSecondary in case of Read-access geo-redundant storage, else set this to PrimaryOnly
LocationMode = LocationMode.PrimaryThenSecondary,
};
CloudTableClient.DefaultRequestOptions = backgroundRequestOption;
return CloudTableClient;
}
Run Code Online (Sandbox Code Playgroud)
当我指定时, …
我想连接到现有的 Azure 存储表并从中读取(过滤后)数据。我找到了一些示例,但每个人都使用已弃用的 WindowsAzure.Storage 命名空间。我无法从当前的 Microsoft 命名空间中找到 Azure.Storage.Common 或其他一些解决方案。Azure.Storage.Blobs 有很多示例,但我需要表存储服务的解决方案。非常感谢 ...
我正在评估奥尔良的一个我们即将开始的新项目。
最终我们想要运行一群持久的演员,但我目前正在努力让奥尔良的内存版本的基线变得高性能。
给定以下颗粒
using Common.UserWallet;
using Common.UserWallet.Messages;
using Microsoft.Extensions.Logging;
namespace Grains;
public class UserWalletGrain : Orleans.Grain, IUserWalletGrain
{
private readonly ILogger _logger;
public UserWalletGrain(ILogger<UserWalletGrain> logger)
{
_logger = logger;
}
public async Task<CreateOrderResponse> CreateOrder(CreateOrderCommand command)
{
return new CreateOrderResponse(Guid.NewGuid());
}
public Task Ping()
{
return Task.CompletedTask;
}
}
Run Code Online (Sandbox Code Playgroud)
以下筒仓配置:
static async Task<IHost> StartSiloAsync()
{
ServicePointManager.UseNagleAlgorithm = false;
var builder = new HostBuilder()
.UseOrleans(c =>
{
c.UseLocalhostClustering()
.Configure<ClusterOptions>(options =>
{
options.ClusterId = "dev";
options.ServiceId = "OrleansBasics";
})
.ConfigureApplicationParts(
parts => parts.AddApplicationPart(typeof(HelloGrain).Assembly).WithReferences()) …Run Code Online (Sandbox Code Playgroud) Windows Azure表存储限制大约是每秒500个请求,请求数量超过此数量,并且会出现DoS,您将收到错误消息.
资料来源:http://blogs.msdn.com/b/mikekelly/archive/2010/04/06/windows-azure-panel-discussion-qa.aspx
我的应用程序平均CRUD操作需要100毫秒,即每秒10.如果我将连接限制设置为50,
<connectionManagement>
<!-- See http://social.msdn.microsoft.com/Forums/en-US/windowsazuredata/thread/d84ba34b-b0e0-4961-a167-bbe7618beb83 -->
<add address="*" maxconnection="50" />
</connectionManagement>
Run Code Online (Sandbox Code Playgroud)
然后,我将在高峰时间只使用一个实例轻松达到Windows Azure表存储请求限制.
我的问题是; 有没有办法增加Windows Azure表存储请求限制?
我正在尝试使用asure sdk 1.6的新upsert功能(针对存储模拟器).
但我只是设法使更新工作.当我尝试为一个新的rowkey upsert时,我得到了resource not found异常.
var context = new TableServiceContext(_cloudStorageAccount.TableEndpoint.ToString(), _cloudStorageAccount.Credentials)
{
MergeOption = MergeOption.NoTracking,
ResolveType = (unused) => typeof(SmartTableServiceEntity)
};
context.AttachTo(tableName, smartEntity, "*");
context.UpdateObject(smartEntity);
context.SaveChangesWithRetries(SaveChangesOptions.ReplaceOnUpdate);
Run Code Online (Sandbox Code Playgroud)
如果我把AddObject它插入但不是更新.由于新的sdk,我一直在考虑能够在一个动作中做到这两点.
我想知道为Azure存储表数据库(而不是SQL Azure)创建数据库模式的专业方法是什么.
对于数据仓库,你通常做starscheme或雪花(OLAP多维数据集),并用大量的交易数据库你可能会做一个规范化的关系数据库(SQL Azure中/ SQL服务器).但是使用Azure存储表并没有任何关系,那么创建专业Azure存储表数据库的最佳做法是什么?
我有一个.NET Core 2.2 Web应用程序,正在尝试与我的Azure表存储资源进行交谈。到目前为止,我有:
using Microsoft.WindowsAzure.Storage;
using Microsoft.Azure.CosmosDB.Table;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace WebApplication1.Repositories
{
public class AssetRepository
{
public AssetRepository()
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse("cstring");
CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
}
}
}
Run Code Online (Sandbox Code Playgroud)
然而,当我将鼠标悬停在CreateCloudTableClient我看到Reference to type CloudStorageAccount claims it is defined in Microsoft.Azure.Storage.Common but it could not be found.
如何在.NET Core 2.2 Web应用程序中执行基本的表CRUD?