使用以下Powershell脚本发布到我们的Azure Web App时,我们经常遇到问题,即先前发布的文件会导致运行时错误.
param($websiteName, $packOutput)
$website = Get-AzureWebsite -Name $websiteName
# get the scm url to use with MSDeploy. By default this will be the second in the array
$msdeployurl = $website.EnabledHostNames[1]
$publishProperties = @{'WebPublishMethod'='MSDeploy';
'MSDeployServiceUrl'=$msdeployurl;
'DeployIisAppPath'=$website.Name;
'Username'=$website.PublishingUsername;
'Password'=$website.PublishingPassword}
Write-Output "Stopping web app..."
Stop-AzureWebsite -Name $websiteName
Write-Output "Publishing web app..."
$publishScript = "${env:ProgramFiles(x86)}\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\Publish\Scripts\default-publish.ps1"
Write-Output "Starting web app..."
Start-AzureWebsite -Name $websiteName
. $publishScript -publishProperties $publishProperties -packOutput $packOutput
Run Code Online (Sandbox Code Playgroud)
如何在发布之前删除所有现有文件?
请注意,我们不能使用插槽,因为这需要标准实例,这对我们的CI环境而言过于昂贵.
假设我们的文档中有一个非唯一的GUID/UUID值:
[
{
"id": "123456",
"Key": "117dfd49-a71d-413b-a9b1-841e88db06e8"
"Name": "Kaapstad",
},
...
]
Run Code Online (Sandbox Code Playgroud)
我们只想通过平等来对此进行查询.无需查询范围或命令.例如:
SELECT * FROM c where c.Key = "117dfd49-a71d-413b-a9b1-841e88db06e8"
Run Code Online (Sandbox Code Playgroud)
下面是索引定义.这是一个哈希索引(因为不会执行范围查询)使用String数据类型(因为Javascript本身不支持Guid)
collection.IndexingPolicy.IncludedPaths.Add(
new IncludedPath {
Path = "/Key/?",
Indexes = new Collection<Index> {
new HashIndex(DataType.String) { Precision = -1 }
}
});
Run Code Online (Sandbox Code Playgroud)
但是这个最好的索引精度是多少?
这个MSDN页面并没有让我明白哪个精度值最适合这样的值:
索引精度配置对字符串范围更有用.由于字符串可以是任意长度,因此索引精度的选择会影响字符串范围查询的性能,并影响所需的索引存储空间量.字符串范围索引可以配置为1-100或-1("最大").如果要对字符串属性执行Order By查询,则必须为相应的路径指定精度-1.
如何project.json在运行时读取版本号?即下面的配置中的"1.0.0-1234":
{
"title": "MyProject.Api",
"webroot": "wwwroot",
"version": "1.0.0-1234",
"dependencies": {
...
},
...
}
Run Code Online (Sandbox Code Playgroud) 我使用ASP.NET和informix数据库.
我使用一组编写的类来处理连接,CRUD操作,事务等....
现在,我觉得这些课程不是最好的选择,性能较差,花费大量时间并且有许多缺点.
我想使用ORM,但我不知道如何选择适合我的Web应用程序的那个(ASP.NET,Informix).
请帮助选择方便的ORM.
我对nHibernate,Entity Framework,LINQ To SQL和Open Access(Telerik组件)感到困惑.
注意:我将使用Visual Studio 2012,所以我想要最近的比较.
假设我有一张表(让我们称之为BigTable),每天可以体验5,000,000个INSERTS(可能只有SELECT).插入的每行约为50kb.
这些每日INSERT分为5个客户端(该表有一个FK调用ClientID).无需跨多个客户端选择或加入数据.
随着这个表的增长,我担心数据库性能,所以我提出了两个解决方案.
解决方案1:
BigTable由ClientID实质上,这意味着他们自己的存储设备上的以下分区:
BigTable)BigTable(每天5,000,000行/ 5个客户x 30天= 30,000,000行)BigTable(30,000,000行)BigTable(30,000,000行)BigTable(30,000,000行)BigTable(30,000,000行)BigTable存档BigTable存档BigTable存档BigTable存档BigTable存档归档表中的行数将为(5,000,000)x(以天为单位的DB年龄) - (30,000,000).这仍然是一个巨大的表,但只会用于绘制奇怪的报告.
SQL Server将托管在14GB,8core Azure VM上.
解决方案2:
另一种选择是为每个客户端托管单独的数据库.这意味着每个人都拥有自己专用的SQL Server机器.归档数据仍将进行分区.
由于数据的物理分离,此选项不是最佳选项.必须管理多个数据库的更新可能非常有问题.为每个客户端建立单独的数据库连接也是开发人员的考虑因素.
任何人都可以就这些选择提出建议吗?
sql-server database-design azure database-performance database-partitioning
我遇到以下Entity Framework查询的性能问题:
using (MyEntities context = new MyEntities())
{
return context.Companies
.Single(c => c.CompanyId == company.CompanyId)
.DataFile.Sum(d => d.FileSize);
}
Run Code Online (Sandbox Code Playgroud)
在SQL事件探查器中进行跟踪时,我看到以下SQL命令:
exec sp_executesql N'SELECT
[Extent1].[DataFileID] AS [DataFileID],
[Extent1].[LocalFileName] AS [LocalFileName],
[Extent1].[ServerFileName] AS [ServerFileName],
[Extent1].[DateUploaded] AS [DateUploaded],
[Extent1].[FileSize] AS [FileSize],
[Extent1].[CompanyID] AS [CompanyID]
FROM [dbo].[DataFile] AS [Extent1]
WHERE [Extent1].[CompanyID] = @EntityKeyValue1',N'@EntityKeyValue1 int',@EntityKeyValue1=16
Run Code Online (Sandbox Code Playgroud)
从我所看到的,所有数据文件行都被返回(超过10,000)到内存然后Sum()正在发生.
编辑:
根据Patryk的建议,我已将查询更改为:
using (MyEntities context = new MyEntities())
{
return context.Companies
.Where(c => c.CompanyId == company.CompanyId)
.Select(x => x.DataFiles.Sum(d => d.FileSize))
.Single();
}
Run Code Online (Sandbox Code Playgroud)
SQL跟踪看起来像这样:
SELECT TOP …Run Code Online (Sandbox Code Playgroud) 我在Windows,Mac和Linux上安装了MongoDB。我使用所有默认参数运行MongoDB,并db.serverStatus().connections在mongo上输入命令以检查可用连接。
这是我的观察,Windows 7具有19999,Mac仅具有203,Linux具有818。因此,我想问一下什么使可用连接数不同,并且是否可以增加可用连接?
谢谢。
域类T可以是以下类型ValueObject<T>:
public class Coordinate: ValueObject<Coordinate>
{ ... }
Run Code Online (Sandbox Code Playgroud)
ValueObject<T>实现IEquatable接口.我希望每个具体的实现都ValueObject<T>提供实现bool Equals(T obj),所以我创建它作为一个抽象方法:
public abstract class ValueObject<T> : IEquatable<T>
{
public abstract bool Equals(T obj);
public static bool operator ==(ValueObject<T> obj1, ValueObject<T> obj2)
{
if (object.ReferenceEquals(obj1, obj2)) return true;
if (object.ReferenceEquals(obj1, null)) return false;
if (object.ReferenceEquals(obj2, null)) return false;
return obj1.Equals(obj2);
}
}
Run Code Online (Sandbox Code Playgroud)
类中的Equals实现Coordinate:
public class Coordinate : ValueObject<Coordinate>
{
// ...
public override bool Equals(Coordinate other)
{
return …Run Code Online (Sandbox Code Playgroud) ConcurrentDictionary我正在循环中填充 a Parallel.ForEach:
var result = new ConcurrentDictionary<int, ItemCollection>();
Parallel.ForEach(allRoutes, route =>
{
// Some heavy operations
lock(result)
{
if (!result.ContainsKey(someKey))
{
result[someKey] = new ItemCollection();
}
result[someKey].Add(newItem);
}
}
Run Code Online (Sandbox Code Playgroud)
如何在不使用 lock 语句的情况下以线程安全的方式执行最后的步骤?
编辑: 假设这ItemCollection是线程安全的。
c# parallel-processing task-parallel-library concurrentdictionary parallel.foreach
抛出以下异常Url.Link(...):
An exception of type 'System.ArgumentException' occurred in System.Web.dll but was not handled in user code
Additional information: A route named 'api/companies/{companyId:Guid}' could not be found in the route collection.
Run Code Online (Sandbox Code Playgroud)
这是控制器方法:
[Route("api/companies/")]
[HttpPost]
public IHttpActionResult Create()
{
Company company = new Company("Test!");
CompanyRepository.Add(company);
return Created(new Uri(Url.Link("api/companies/{companyId:Guid}", new { companyId = company.Id })), company);
}
Run Code Online (Sandbox Code Playgroud)
此处使用属性路由定义路由:
[Route("api/companies/{companyId:Guid}")]
[HttpGet]
public IHttpActionResult Get(Guid companyId)
{
return Ok(CompanyRepository.Find(companyId));
}
Run Code Online (Sandbox Code Playgroud)
为什么无法找到路线? 我需要在传统路由中使用RouteConfig吗?
c# ×4
azure ×3
.net ×2
sql-server ×2
asp.net ×1
asp.net-core ×1
iequatable ×1
inheritance ×1
linq ×1
linq-to-sql ×1
mongodb ×1
msdeploy ×1
nhibernate ×1
powershell ×1
project.json ×1