以下方法可用于将实体集合批量插入为单个事务:
CloudTable.ExecuteBatch(TableBatchOperation batch)
Run Code Online (Sandbox Code Playgroud)
如果在插入期间任何实体失败,则不会从集合中插入任何内容.这仅在插入一个分区时可用.
是否可以跨多个分区执行此类操作?
我们有一个具有隐式字符串运算符的类型.它看起来像这样:
public class Foo
{
readonly string _value;
Foo(string value)
{
_value = value;
}
public static implicit operator string(Foo foo)
{
return foo._value;
}
public static implicit operator Foo(string fooAsText)
{
return new Foo(fooAsText);
}
}
Run Code Online (Sandbox Code Playgroud)
我们刚刚有一个实例传递给隐式运算符null的场景.显然,我们最终得到了一个NullReferenceException.
我认为这是很公平的,毕竟,什么是一个类型,它是空的字符串表示 - 很难说 - 这样的例外似乎是有效的,这是我们不应该拦截/禁止/手柄/忽略.我的理由是'有人给我一个空的,为什么我应该返回null.我不会在其他方法中这样做.我想,'我知道,我会在转换之前检查null',类似于:
string s = foo == null ? null : foo;
但这没有用,因为它现在在比较之前转换为字符串为null.当然,这种比较可行:
Foo f = null;
string s;
if (f != null)
{
s = f;
}
Run Code Online (Sandbox Code Playgroud)
......但那只是丑陋的.
我阅读了Essential …
在发布到Azure Web Apps时,最好为ASP.NET 5 Web应用程序的每个部署设置环境名称?
我知道ASPNET_DEV需要设置环境变量.发布时这可能吗?
这是我们的powershell发布脚本:
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 "Restarting web app..."
Restart-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"
. $publishScript -publishProperties $publishProperties -packOutput $packOutput
Run Code Online (Sandbox Code Playgroud)
或者我们是否在Azure门户中设置了环境变量?部署之间会持续存在吗?
我正在使用ASP.NET 5 beta6库与dnx451目标框架,如果这很重要.
我将X509Certificate存储在数据库(in byte[])中,以便我的应用程序可以检索证书并使用它来签署我的JWT.
我的x509Certificate是从我在我的机器上生成的.pfx文件传递出来的,但现在它作为字节串存在于数据库中.
我运行它时,我的应用程序在本地工作得很好.应用程序可以正确创建该X509Certificate2的实例并将其用于我的要求,但是当我尝试在我的azurewebsites Web应用程序中使用它时会出现问题.
基本上我无法访问证书的PrivateKey实例变量,我得到一个例外
System.Security.Cryptography.CryptographicException: Keyset does not exist
Run Code Online (Sandbox Code Playgroud)
我正在用这个重新实例化证书
var cert = new X509Certificate2(myCertInBytes, myCertPass,
X509KeyStorageFlags.PersistKeySet |
X509KeyStorageFlags.MachineKeySet |
X509KeyStorageFlags.Exportable);
Run Code Online (Sandbox Code Playgroud)
我正在使用ASPNET 5 rc1-update1.我也试过在另一台机器上运行它,它工作正常,只有在我发布到Azure时才会出现这个问题.并且还要添加其他内容,当我运行使用DNX版本beta7运行的相同项目时,此应用程序正在运行
任何帮助赞赏.
当401和403出现时,我想用JSON响应模型做出响应.例如:
HTTP 401
{
"message": "Authentication failed. The request must include a valid and non-expired bearer token in the Authorization header."
}
Run Code Online (Sandbox Code Playgroud)
我正在使用中间件(如本答案中所建议的)拦截404并且它工作得很好,但401或403并非如此.这是中间件:
app.Use(async (context, next) =>
{
await next();
if (context.Response.StatusCode == 401)
{
context.Response.ContentType = "application/json";
await context.Response.WriteAsync(JsonConvert.SerializeObject(UnauthorizedModel.Create(), SerializerSettings), Encoding.UTF8);
}
});
Run Code Online (Sandbox Code Playgroud)
当置于下方app.UseJwtBearerAuthentication(..)时Startup.Configure(..),它似乎被完全忽略并返回正常的401.
当置于ABOVE app.UseJwtBearerAuthentication(..)中时Startup.Configure(..),将抛出以下异常:
连接标识"0HKT7SUBPLHEM":应用程序抛出了未处理的异常.System.InvalidOperationException:标头是只读的,响应已经开始.在MicrosoftPro.AspNetCore.Server.Kestrel.Internal.Http.FrameHeaders.Microsoft.AspNetCore.Http.IHeaderDictionary.set_Item(String key,StringValues value),位于MyProject的Microsoft.AspNetCore.Http.Internal.DefaultHttpResponse.set_ContentType(String value). Startup.cs中的Api.Startup.<b__12_0> d.MoveNext()
我们突然开始The specified CGI application encountered an error and the server terminated the process从我们的Web应用程序的一个实例中遇到HTTP 502错误().我能够使用Kudu的"支持"选项卡确定这一点,您可以深入查看每个实例的指标.
重新启动w3wp后,所有内容都正常继续成功.资源使用(CPU/RAM)没有问题,奇怪的是502s立即返回.因此,请求不会为客户端超时.
调查为什么会发生这种情况的可能步骤是什么?
我们的应用程序日志没有任何内容,我们的Web服务器日志只有这些502的记录,但没有进一步的细节.
azure azure-diagnostics azure-web-sites azure-app-service-envrmnt azure-app-service-plans
我们已将Azure Kubernetes Clusters配置为使用Azure Active Directory RBAC.这意味着当使用kubectl时,我们需要首先作为AD用户进行身份验证(通常通过Web浏览器手动完成设备代码身份验证).我们几乎完全按照MSDN文章" 将Azure Active Directory与Azure Kubernetes服务集成"进行了配置.
问题是,现在,Azure DevOp管道中的Kubernetes构建/发布任务也需要此身份验证,例如,当我们运行kubectl apply时:
2019-01-02T08:48:21.2070286Z ##[section]Starting: kubectl apply
2019-01-02T08:48:21.2074936Z ==============================================================================
2019-01-02T08:48:21.2075160Z Task : Deploy to Kubernetes
2019-01-02T08:48:21.2075398Z Description : Deploy, configure, update your Kubernetes cluster in Azure Container Service by running kubectl commands.
2019-01-02T08:48:21.2075625Z Version : 1.1.17
2019-01-02T08:48:21.2075792Z Author : Microsoft Corporation
2019-01-02T08:48:21.2076009Z Help : [More Information](https://go.microsoft.com/fwlink/?linkid=851275)
2019-01-02T08:48:21.2076245Z ==============================================================================
2019-01-02T08:48:25.7971481Z Found tool in cache: kubectl 1.7.0 x64
2019-01-02T08:48:25.7980222Z Prepending PATH environment variable with directory: C:\agents\HephaestusForge\_work\_tool\kubectl\1.7.0\x64
2019-01-02T08:48:25.8666111Z [command]C:\agents\HephaestusForge\_work\_tool\kubectl\1.7.0\x64\kubectl.exe apply -f C:\agents\HephaestusForge\_work\r8\a\_MyProject\kubernetes\deploy.yaml …Run Code Online (Sandbox Code Playgroud) azure azure-active-directory azure-devops azure-pipelines azure-kubernetes
我们有3个面向公众的Web应用程序,我们正在迁移到Azure.所有站点都使用端口80.
OPTIONS
据我所知,使用Web角色时有三种不同的选择:
1.在单个云服务中以一个Web角色托管的所有3个站点:
ServiceDefinition.csdef2.在单个云服务中托管在SEPARATE Web角色上的每个站点:
ServiceDefinition.csdef3.在SEPARATE云服务中的Web角色上托管的每个站点:
我还缺少其他重要的东西吗?
可能的解决方案
选项1和2的组合.
在一个云服务中托管所有内容:将它们全部发布在一起很好,因为它们都引用了一个需要在所有项目中一致更新的公共库项目.
在一个Web角色中托管两个站点:它们可以很好地扩展.
在其自己的Web角色中托管第三个站点由于大量的峰值需求,它需要自己的扩展.
ServiceDefinition.csdef:
<ServiceDefinition name="WebTestCloudService.Test" xmlns="..." schemaVersion="2012-10.1.8">
<WebRole name="AzureWebTest1" vmsize="Small">
<Sites>
<Site name="AzureWebTest1">
<Bindings>
<Binding name="Endpoint1" endpointName="Endpoint1" hostHeader="test1.mydomain.com" />
</Bindings>
</Site>
</Sites>
<Endpoints>
<InputEndpoint name="Endpoint1" protocol="http" port="80" />
</Endpoints>
</WebRole>
<WebRole name="AzureWebTest2" vmsize="Small">
<Sites> …Run Code Online (Sandbox Code Playgroud) 在Web Api 2.2中,我们可以通过从控制器返回来返回位置标头URL,如下所示:
return Created(new Uri(Url.Link("GetClient", new { id = clientId })), clientReponseModel);
Run Code Online (Sandbox Code Playgroud)
Url.Link(..)将根据控制器名称相应地解析资源URL GetClient:
在ASP.NET 5 MVC 6的Web Api中,Url框架中不存在但CreatedResult构造函数确实具有location参数:
return new CreatedResult("http://www.myapi.com/api/clients/" + clientId, journeyModel);
Run Code Online (Sandbox Code Playgroud)
如何在不必手动提供此URL的情况下解析此URL,就像我们在Web API 2.2中所做的那样?