我正在使用Azure SDK 2.5在.NET中编写新的Cloud Service.我知道使用2.5 SDK rekesae对诊断进行了一些重大更改.
我收到相互矛盾的信息的地方是我是否仍然可以使用Azure诊断将Trace.*输出捕获到WADLogsTableAzure表存储中?
我知道我可以使用ETW替代,但现在我正在要求它.
根据这篇文章,我仍然可以使用Trace来使用Azure Diagnostics 1.3捕获我的日志 - 据我所知,它已随SDK 2.5一起提供.
不幸的是我无法让它发挥作用.
我的worker角色的app.config如下所示:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.diagnostics>
<trace>
<listeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=2.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="AzureDiagnostics">
<filter type="" />
</add>
</listeners>
</trace>
</system.diagnostics>
</configuration>
Run Code Online (Sandbox Code Playgroud)
在我的worker角色的代码中,我有跟踪代码,如下所示:
Trace.TraceInformation("Something happened");
Run Code Online (Sandbox Code Playgroud)
我的公共diagnostics.wadcfg文件如下所示:
<?xml version="1.0" encoding="utf-8"?>
<PublicConfig xmlns="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration">
<WadCfg>
<DiagnosticMonitorConfiguration overallQuotaInMB="4096">
<Logs scheduledTransferPeriod="PT1M" scheduledTransferLogLevelFilter="Information" />
</DiagnosticMonitorConfiguration>
</WadCfg>
<StorageAccount>mystorageAccount</StorageAccount>
</PublicConfig>
Run Code Online (Sandbox Code Playgroud)
我使用此文件使用PowerShell命令配置诊断服务扩展:
Set-AzureServiceDiagnosticsExtension
Run Code Online (Sandbox Code Playgroud)
没有创建WADLogsTable.如果我启用其他诊断服务(如Perf Counter),则会创建并填充相关表(WADPerformanceCountersTable).
我在用:
请考虑以下类,该类负责使用.NET HttpClient与API进行通信.
public class ApiServiceAgent
{
public async Task<string> GetItem()
{
var client = new HttpClient();
var uri = new Uri("http://stackoverflow.com");
var response = await client.GetAsync(uri);
return await response.Content.ReadAsStringAsync();
}
}
Run Code Online (Sandbox Code Playgroud)
虽然简化了,但它代表了我如何编写与HTTP API通信的代码.
现在考虑我希望在我自己的Web API项目中使用这个类.为简单起见,我可以说我有两个额外的类(直接或其他方式)调用此类.
这两个类可能是这样的:
public class Controller : ApiController
{
public async Task<string> Get()
{
var repository = new Repository();
return await repository.GetItem();
}
}
public class Repository
{
public async Task<string> GetItem()
{
var serviceAgent …Run Code Online (Sandbox Code Playgroud) 考虑以下输入:BEGINsomeotherstuffEND
我正在尝试编写一个正则表达式来替换BEGIN和END,但前提是它们都存在.
我得到了:
(^BEGIN|END$)
Run Code Online (Sandbox Code Playgroud)
使用以下c#代码然后执行我的字符串替换:
private const string Pattern = "(^guid'|'$)";
private static readonly Regex myRegex = new Regex(Pattern, RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.ExplicitCapture | RegexOptions.Singleline | RegexOptions.IgnoreCase);
var newValue = myRegex.Replace(input, string.empty);
Run Code Online (Sandbox Code Playgroud)
但不幸的是,它们中的任何一个都匹配 - 不仅在它们都存在时.
我也尝试过:
^BEGIN.+END$
Run Code Online (Sandbox Code Playgroud)
但是它会捕获整个字符串,因此整个字符串将被替换.
这与我的正则表达知识有关.
救命!
我正在尝试编写一个plsql查询,它允许我查询一组未存储在表中的已知值.假设这些已知值是以下字符串:
我想实现以下内容:
select * from [fill-in-the-blank] myvalues
where not myvalues in
(
select id from dbtable
)
..我试图确定哪些知识值不在数据库表中.
约束
有任何想法吗?