我有一个 Azure Web 应用程序,它通过 VPN/VNET 集成与 3rd 方系统进行通信。该通信的一部分依赖于解析 DNS 名称的能力。
当应用程序部署到虚拟机时,我们只需使用如下条目更新主机文件
123.45.67.89 RPGMDR500-0R
并且通讯正常。由于通信的设置方式,我不能只在代码中使用 IP 地址。在通信中,DNS 名称被发回给我们,我们必须将其解析为该 IP 地址。
有没有办法只用一个应用服务来做到这一点?实际上,我们希望应用程序将此自定义 dns 名称解析为 ip 地址。
更新 我更新了我们的 VNET DNS 服务器以使用虚拟机设置进行 DNS。
使用 nameresolver,我可以看到 DNS 正在访问应用程序服务,但前提是我指定了 DNS IP 地址。默认情况下,它仍在使用默认服务器(不确定如何)。(对于停电很抱歉,不确定这些数据有多敏感)。
我有一堆服务发出System.Diagnostics.Trace.*
跟踪消息.当通过ASP.NET WebAPI托管时,我只需包含该Microsoft.ApplicationInsights.TraceListener
软件包,并在应用程序洞察中收集服务库中的自定义跟踪.
但是,在通过ASP.NET Core 2.0 WebAPI托管服务时,我无法弄清楚如何获取这些相同的消息.我试过的......
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddApplicationInsights(app.ApplicationServices, Microsoft.Extensions.Logging.LogLevel.Information);
//...
}
Run Code Online (Sandbox Code Playgroud)
在使用扩展方法添加应用程序洞察之后,我能够看到框架发出的跟踪(例如,Request Start,Request End,...),但是我的自定义跟踪消息都不存在.
我决定添加一下Microsoft.ApplicationInsights.TraceListener
包,看看是否有帮助.我更新了configure方法,看起来像这样......
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddTraceSource(new System.Diagnostics.SourceSwitch("AppInsightsTraceSwitch")
{
Level = System.Diagnostics.SourceLevels.All
}, new Microsoft.ApplicationInsights.TraceListener.ApplicationInsightsTraceListener());
loggerFactory.AddApplicationInsights(app.ApplicationServices, Microsoft.Extensions.Logging.LogLevel.Information);
}
Run Code Online (Sandbox Code Playgroud)
更新配置后,我现在看到日志中重复的跟踪消息,但仍然没有任何自定义跟踪.
我刚刚开始失败,不知道为什么; 它昨天工作正常.我只是将appsettings和connectionstrings更改为部分或资源而不是webapp,以将dependsOn移动到链中.以前,该网站取决于应用程序设置和连接字符串的依赖关系.这是网站资源的ARM模板.
{
"comments": "Primary web app deployment.",
"name": "[variables('webAppName')]",
"type": "Microsoft.Web/sites",
"apiVersion": "2016-08-01",
"kind": "app",
"location": "[variables('rgLocation')]",
"tags": {},
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms', variables('planName'))]"
],
"properties": {
"enabled": true,
"hostNameSslStates": [
{
"name": "[concat(variables('webAppName'), '.azurewebsites.net')]",
"sslState": "Disabled"
},
{
"name": "[concat(variables('webAppName'), '.scm.azurewebsites.net')]",
"sslState": "Disabled"
}
],
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('planName'))]",
"siteConfig": {
"numberOfWorkers": 1,
"defaultDocuments": [
"Default.htm",
"Default.html",
"Default.asp",
"index.htm",
"index.html",
"iisstart.htm",
"default.aspx",
"index.php",
"hostingstart.html"
],
"netFrameworkVersion": "v4.6",
"phpVersion": "",
"pythonVersion": "",
"nodeVersion": "",
"linuxFxVersion": "",
"requestTracingEnabled": false,
"remoteDebuggingEnabled": false,
"remoteDebuggingVersion": …
Run Code Online (Sandbox Code Playgroud) 这个问题在发布后似乎随机发生. 该网站将正常工作,然后bam,我得到这个错误解析webconfig.我只是重新发布,它再次正常工作.发布时,我选中了该框以删除现有文件,因此不应该存在垃圾.
这是一个使用.net 4.5和Azure访问控制服务(ACS)与Yahoo!集成的MVC4项目.从Yahoo重定向时会发生此错误.这种方式每次都会发生,但我发现了一个帖子(当然我现在找不到),其中4.5.1 Identity和Access Visual Studio集成存在错误.我去了以前的版本,现在只是有时候.
ID8030:无法解析'type'属性的值.
验证'<issuerNameRegistry type="System.IdentityModel.Tokens.ValidatingIssuerNameRegistry, System.IdentityModel.Tokens.ValidatingIssuerNameRegistry"><authority name="[my authority]"><keys><add thumbprint="[print]" /></keys><validIssuers><add name="[issuer]" /></validIssuers></authority></issuerNameRegistry>'
元素的type属性是否正确.
在上面的错误消息中,我已替换此帖子的括号([])中的项目.
这是堆栈跟踪:
[TypeLoadException: ID8030: The value of the 'type' property could not be parsed. *** element is correct.]
System.IdentityModel.Configuration.TypeResolveHelper.Resolve(ConfigurationElementInterceptor customTypeElement, Type customType) +602659
System.IdentityModel.Configuration.IdentityConfiguration.GetIssuerNameRegistry(IssuerNameRegistryElement element) +114
System.IdentityModel.Configuration.IdentityConfiguration.LoadHandlerConfiguration(IdentityConfigurationElement element) +841
System.IdentityModel.Configuration.IdentityConfiguration.LoadConfiguration(IdentityConfigurationElement element) +117
System.IdentityModel.Configuration.IdentityConfiguration..ctor(String identityConfigurationName) +180
System.IdentityModel.Services.Configuration.FederationConfiguration.LoadConfiguration(FederationConfigurationElement element) +392
System.IdentityModel.Services.Configuration.FederationConfiguration..ctor(Boolean loadConfig) +94
System.IdentityModel.Services.FederatedAuthentication.CreateFederationConfiguration() +71
System.IdentityModel.Services.FederatedAuthentication.get_FederationConfiguration() +85
System.IdentityModel.Services.HttpModuleBase.Init(HttpApplication context) +56
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +418
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr …
Run Code Online (Sandbox Code Playgroud) 我最近和一个伙伴讨论过返回值只有一个含义.在我之前的工作中,我们使用C++并使用了typedef'ed wBOOL,因此0为wFALSE,1为wTRUE.建筑师说我们也可以返回2,3,4 ......以获取更多信息,我认为这是一个可怕的想法.如果我们期望wTRUE = 1且wFALSE = 0且wBOOL = {wTRUE,wFALSE},则应该避免返回任何其他内容......现在,转到今天的C#.
我最近审查了一段代码,其中有一组函数确定是否存在错误并将字符串返回给用户:
private bool IsTestReady(out string errorMessage)
{
bool isReady = true;
errorMessage = string.Empty;
if(FailureCondition1)
{
isReady = false;
errorMessage = FailureMessage1;
}
else if(FailureCondition2)
{
isReady = false;
errorMessage = FailureMessage2;
}
//... other conditions
return isReady;
}
Run Code Online (Sandbox Code Playgroud)
然后,使用这些功能......
private enum Tests
{ TestA, TestB, TestC }
private void UpdateUI()
{
string error = string.Empty;
bool isTestReady;
switch(this.runningTest) // which test are we running (TestA, TestB, or TestC)
{
case …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Powershell DSC安装URL重写器并且它一直在失败.当我删除安装重写器的步骤时,脚本会成功.
我的设置是使用Visual Studio Team Services(VSTS)构建和发布管道我执行ARM模板来创建一个缩放集,指向powershell dsc脚本.
"extensionProfile": {
"extensions": [
{
"name": "Microsoft.Powershell.DSC",
"properties": {
"publisher": "Microsoft.Powershell",
"type": "DSC",
"typeHandlerVersion": "2.72",
"autoUpgradeMinorVersion": true,
"forceUpdateTag": "[parameters('dscVmssUpdateTagVersion')]",
"settings": {
"configuration": {
"url": "https://myblobname.blob.core.windows.net/dsc/scalesetSetup.zip",
"script": "prepareServer.ps1",
"function": "PrepareServer"
},
"configurationArguments": {
"nodeName": "localhost",
"envName": "[parameters('envName')]"
}
}
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
在这个脚本中,我正在启用Windows功能,安装Web部署和URL重写器.当没有安装重写器时一切正常,但是当我以下列任何一种方式添加它时失败.
DSC脚本实际上看起来像:
Configuration PrepareServer
{
Param ( [string] $nodeName, [string] $envName )
Import-DscResource -ModuleName PSDesiredStateConfiguration
Node $nodeName
{
# Web Server
WindowsFeature WebServerRole
{
Name = "Web-Server"
Ensure = "Present"
} …
Run Code Online (Sandbox Code Playgroud) 所以主要是我在这里寻找最佳实践.我有一个系统,它基本上是一组规则,一些数据和一个管理器,以确保数据遵循规则.很简单.我试图找出处理保存和加载规则的最佳方法.对于第一次尝试,我有一个名为IRule的接口,所有规则都继承.
interface IRule
{
/* all rules inherit this */
string RuleName {get;}
}
interface IRuleTypeA : IRule
{
/* Type A Rules */
double[] Data;
}
interface IRuleTypeB : IRule
{
/* Type B Rules */
double[,] Data;
}
public static class IRuleExtensions
{
XElement AsXml(this IRuleTypeA ruleA)
{
//format my data my way and return an XElement representation
return new XElement(...);
}
XElement AsXml(this IRuleTypeB ruleB)
{
//format my different data in a different way and return an …
Run Code Online (Sandbox Code Playgroud) azure ×4
c# ×2
acs ×1
asp.net-core ×1
dns ×1
dsc ×1
powershell ×1
return-type ×1
save ×1
web-config ×1
xml ×1