I'm using the anomaly detector with .NET 5 and the code here
What should be the signature of the Main Method? At the moment it's
public async Task Main(string[] args)
I'm getting these error message:
can't convert type void to system.guid
Severity Code Description Project File Line Suppression State Error CS1997 Since 'Program.trainAsync(AnomalyDetectorClient, string, DateTimeOffset, DateTimeOffset, int)' is an async method that returns 'Task', a return keyword must not be followed by an object expression. Did you intend to return 'Task'? anomaly-detector-quickstart-multivariate C:\CognitiveSvs\Anomalies\anomaly-detector-quickstart-multivariate\Program.cs 116 Active
Also, there is a statement using Azure.Core.TestFramework; which doesn't seem to exist. What should I use in its place?
Is there any sample data I can use for univariate and multivariate analysis?
I think the example code is not correct (or not correctly displayed).
The error is not about the Main
method but, about the trainAsync
method.
CS1997 Since 'Program.trainAsync(AnomalyDetectorClient, string, DateTimeOffset, DateTimeOffset, int)' is an async method that returns 'Task', a return keyword must not be followed by an object expression. Did you intend to return 'Task'? anomaly-detector-quickstart-multivariate C:\CognitiveSvs\Anomalies\anomaly-detector-quickstart-multivariate\Program.cs 116
Which is described as follows in your link:
private async Task trainAsync(AnomalyDetectorClient client, string datasource, DateTimeOffset start_time, DateTimeOffset end_time, int max_tryout = 500)
{
...
According the error message you receive, and the source for the documentation and the actual code of the method (which returns a Guid
), this is the correct signature for the trainAsync
method:
private async Task<Guid?> trainAsync(AnomalyDetectorClient client, string datasource, DateTimeOffset start_time, DateTimeOffset end_time, int max_tryout = 500)
{
...