How can I get the list of test results for a given test case using azure devops API ?
var testResultsQuery = new TestResultsQuery
{
ResultsFilter = new ResultsFilter
{
TestCaseId = validTestCaseId
}
};
var testCaseResults = await _testClient.GetTestResultsByQueryAsync(testResultsQuery, projectName).ConfigureAwait(false);
This code results in an internal error (500) from the API.
You need to specify the GroupBy and AutomatedTestName properties for ResultsFilter too. Please specify them in ResultsFilter. See below example:
var testResultsQuery = new TestResultsQuery
{
ResultsFilter = new ResultsFilter
{
AutomatedTestName="AutoTestName",
GroupBy = "branch",
TestCaseId = 149
}
};
Related
I am using the FabricClient QueryManager to iterate over all partitions to find all actors and return a list. This works fine on my local cluster but throws InvalidCastException when running in our Azure sandbox. Specifically, "Unable to cast object of type 'System.Fabric.SingletonPartitionInformation' to type 'System.Fabric.Int64RangePartitionInformation'."
public async Task<List<Store>> GetStores()
{
var cancelToken = new CancellationToken(false);
var fabricClient = new FabricClient();
var actorServiceUri = new ServiceUriBuilder("StoreActorService").ToUri();
var partitions = await fabricClient.QueryManager.GetPartitionListAsync(actorServiceUri);
var actorIds = new List<ActorId>();
foreach (var partition in partitions)
{
// the following cast works locally but throws InvalidCast in our Azure sandbox
var partitionInfo = (Int64RangePartitionInformation)partition.PartitionInformation;
var actorServiceProxy = ActorServiceProxy.Create(
actorServiceUri,
partitionInfo.LowKey);
var continueToken = (ContinuationToken)null;
do
{
var page = await actorServiceProxy.GetActorsAsync(continueToken, cancelToken);
actorIds.AddRange(page.Items.Select(actor => actor.ActorId));
continueToken = page.ContinuationToken;
} while (continueToken != null);
}
var stores = new List<Store>();
foreach (var actorId in actorIds)
{
var proxy = ActorProxy.Create<IStoreActor>(actorId, actorServiceUri);
var store = await proxy.RetrieveAsync(actorId.ToString());
stores.Add(store);
}
return stores;
}
As shown in Service Fabric Explorer, the service is partitioned for Int64Range as required.
Any thoughts on why Azure thinks it's a SingletonPartition?
Thanks.
Chuck
It turns out that somehow this Actor Service did get created in a Singleton Partition in our Sandbox environment, but not in either local or production environments. I didn't think this was possible, but I guess it is.
I am trying to get Amazon's Route53 Recovery Controller to update control states from a .net application and I keep getting an error. I see on the documentation that I need to set the region and cluster endpoint, but I can't figure out how to do it.
Here a sample of the code I am using:
AmazonRoute53RecoveryControlConfigConfig configConfig = new AmazonRoute53RecoveryControlConfigConfig();
configConfig.RegionEndpoint = RegionEndpoint.USWest2;
AmazonRoute53RecoveryControlConfigClient configClient = new AmazonRoute53RecoveryControlConfigClient(_awsCredentials, configConfig);
DescribeClusterResponse describeClusterResponse = await configClient.DescribeClusterAsync(new DescribeClusterRequest()
{
ClusterArn = "arn:aws:route53-recovery-control::Account:cluster/data"
});
foreach (ClusterEndpoint clusterEndpoint in describeClusterResponse.Cluster.ClusterEndpoints)
{
AmazonRoute53RecoveryClusterConfig clusterConfig = new AmazonRoute53RecoveryClusterConfig();
clusterConfig.RegionEndpoint = RegionEndpoint.GetBySystemName(clusterEndpoint.Region);
AmazonRoute53RecoveryClusterClient client = new AmazonRoute53RecoveryClusterClient(_awsCredentials, clusterConfig);
GetRoutingControlStateResponse getRoutingControlStateResponseWest = await client.GetRoutingControlStateAsync(new GetRoutingControlStateRequest()
{
RoutingControlArn = "arn:aws:route53-recovery-control::Account:controlpanel/data/routingcontrol/data"
});
GetRoutingControlStateResponse getRoutingControlStateResponseEast = await client.GetRoutingControlStateAsync(new GetRoutingControlStateRequest()
{
RoutingControlArn = "arn:aws:route53-recovery-control::Account:controlpanel/data/routingcontrol/data"
});
UpdateRoutingControlStatesRequest request = new UpdateRoutingControlStatesRequest();
request.UpdateRoutingControlStateEntries = new List<UpdateRoutingControlStateEntry>()
{
new UpdateRoutingControlStateEntry()
{
RoutingControlArn = "arn:aws:route53-recovery-control::Account:controlpanel/data/routingcontrol/data",
RoutingControlState = getRoutingControlStateResponseWest.RoutingControlState == RoutingControlState.On ? RoutingControlState.Off : RoutingControlState.On
},
new UpdateRoutingControlStateEntry()
{
RoutingControlArn = "arn:aws:route53-recovery-control::Account:controlpanel/data/routingcontrol/data",
RoutingControlState = getRoutingControlStateResponseEast.RoutingControlState == RoutingControlState.On ? RoutingControlState.Off : RoutingControlState.On
}
};
UpdateRoutingControlStatesResponse response = await client.UpdateRoutingControlStatesAsync(request);
if (response.HttpStatusCode == HttpStatusCode.OK)
{
break;
}
}
When this code executes I get this error when it tries to get the control state: The requested name is valid, but no data of the requested type was found.
I see in the java example you can set the region and the data plane url endpoint, but I don't see the equivalent in .net.
https://docs.aws.amazon.com/r53recovery/latest/dg/example_route53-recovery-cluster_UpdateRoutingControlState_section.html
This works when I use the cli which I can also set the region and url endpoint.
https://docs.aws.amazon.com/r53recovery/latest/dg/getting-started-cli-routing.control-state.html
What am I doing wrong here?
There is a solution to this question here: https://github.com/aws/aws-sdk-net/issues/1978.
Essentially use the ServiceURL on the configuration object and add a trailing / to the endpoint url.
AmazonRoute53RecoveryClusterConfig clusterRecoveryConfig = new AmazonRoute53RecoveryClusterConfig();
clusterRecoveryConfig.ServiceURL = $"{clusterEndpoint.Endpoint}/";
AmazonRoute53RecoveryClusterClient client = new AmazonRoute53RecoveryClusterClient(_awsCredentials, clusterRecoveryConfig);
I created an ADF pipeline using the Azure Data Factory UI that triggers a run once every day. Is there a way to get latest pipeline run id & monitor that run using .NET SDK? Please provide a console application that does the same with an existing ADF pipeline run?
This is what I tried where a pipeline is created using .NET SDK and monitor run (https://learn.microsoft.com/en-us/azure/data-factory/quickstart-create-data-factory-dot-net):
static async Task Main(string[] args)
{
// Authenticate and create a data factory management client
var context = new AuthenticationContext("https://login.windows.net/" + tenantID);
ClientCredential cc = new ClientCredential(applicationId, authenticationKey);
AuthenticationResult result = context.AcquireTokenAsync(
"https://management.azure.com/", cc).Result;
ServiceClientCredentials cred = new TokenCredentials(result.AccessToken);
using (var client = new DataFactoryManagementClient(cred) {
SubscriptionId = subscriptionId
})
{
RunQueryFilter filter1 = new RunQueryFilter("PipelineName", "Equals", new List<string> { "Pipeline" });
DateTime before = DateTime.UtcNow;
DateTime after = before.AddHours(-24);
RunFilterParameters param = new RunFilterParameters(after, before, null, new List<RunQueryFilter> { filter1 }, null);
PipelineRunsQueryResponse pipelineResponse = client.PipelineRuns.QueryByFactory(
resourceGroup,
dataFactoryName, param
);
}
// Monitor the pipeline run
Console.WriteLine("Checking pipeline run status...");
PipelineRun pipelineRun;
while (true)
{
pipelineRun = client.PipelineRuns.Get(
resourceGroup, dataFactoryName, runResponse.RunId);
Console.WriteLine("Status: " + pipelineRun.Status);
if (pipelineRun.Status == "InProgress" || pipelineRun.Status == "Queued")
System.Threading.Thread.Sleep(15000);
else
break;
}
}
but is it possible to monitor the run by getting latest run id from ADF?
Step1,please see IPipelineRunsOperations.QueryByFactoryWithHttpMessagesAsync method.
Step2: Navigate to RunFilterParameters Class, you could find the property named OrderBy.
Step3: Find RunQueryOrderBy Class and you could see it accepts 2 parameters. Here, you could set them as RunEnd and DESC.
Step4: Just get the first element of the Pipeline Runs List.
I have a bugs list managed in a WPF app. I would like to create the bug in the VSO work item. Is there an API available to create work items like bug or task in Visual Studio Online?
Yes, there has the REST API to create a work item. The example code as:
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using Newtonsoft.Json;
...
public void CreateBug()
{
string _personalAccessToken = "your personal access token";
string _credentials = Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(string.Format("{0}:{1}", "", _personalAccessToken)));
Object[] patchDocument = new Object[4];
patchDocument[0] = new { op = "add", path = "/fields/System.Title", value = "Authorization Errors" };
patchDocument[1] = new { op = "add", path = "/fields/Microsoft.VSTS.TCM.ReproSteps", value = "Our authorization logic needs to allow for users with Microsoft accounts (formerly Live Ids) - http://msdn.microsoft.com/en-us/library/live/hh826547.aspx" };
patchDocument[2] = new { op = "add", path = "/fields/Microsoft.VSTS.Common.Priority", value = "1" };
patchDocument[3] = new { op = "add", path = "/fields/Microsoft.VSTS.Common.Severity", value = "2 - High" };
//use the httpclient
using (var client = new HttpClient())
{
//set our headers
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", _credentials);
//serialize the fields array into a json string
var patchValue = new StringContent(JsonConvert.SerializeObject(patchDocument), Encoding.UTF8, "application/json-patch+json");
var method = new HttpMethod("PATCH");
var request = new HttpRequestMessage(method, "https://accountname.visualstudio.com/fabrikam/_apis/wit/workitems/$Bug?api-version=2.2") { Content = patchValue };
var response = client.SendAsync(request).Result;
//if the response is successfull, set the result to the workitem object
if (response.IsSuccessStatusCode)
{
var result = response.Content.ReadAsStringAsync().Result;
}
}
}
More details, you can refer create bug.
I am creating Facebook application which get insights for user's page for multiple metric. Ex. for "page_active_users" and "page_active_users in one batch request.
I am using Facebook C# SDK. But not able to get data from Facebook insights (GraphAPI).
I used 5 different way to get the data but not succeed. By using Graph API method in browser shows data for a page but in batch request it returns empty array of data.
//type1
var para1 = new FacebookBatchParameter(HttpMethod.Get, "MyPageId/insights/")
{
Data = new { access_token = aToken, since = "2012-01-01", metric = "page_active_users" }
};
//type2
var para2 = new FacebookBatchParameter(HttpMethod.Get, "fql/", new
{
q = new[]{
"SELECT value,end_time FROM insights WHERE object_id=MyPageId AND metric='page_active_users' AND end_time=end_time_date('2012-01-01') AND period=86400"
}
}) { Data = new { access_token = aToken } };
//type 3
var para3 = new FacebookBatchParameter().Query(
"SELECT value,end_time FROM insights WHERE object_id=MyPageId AND metric='page_active_users' AND end_time=end_time_date('2012-01-01') AND period=86400");
//type 4
var para4 = new FacebookBatchParameter
{
Path = "MyPageId/insights/",
//Parameters = new {since = "2012-01-01"},
Data = new { access_token = aToken, since = "2012-01-01", metric = "page_active_users" },
HttpMethod = HttpMethod.Get
};
//type 5
var para5 = new FacebookBatchParameter
{
Path = "MyPageId/insights/page_active_users?since=2012-01-01",
//Parameters = new {since = "2012-01-01"},
Data = new { access_token = aToken },
HttpMethod = HttpMethod.Get
};
//Executed all above type by passing it to below method one by one.But always return empty data array while data is exists on Facebook which I tested using Grap API tool.
var result = client.Batch(para1-5);
Any help appreciated.
Thanks in advanced.
Dharmendra Mistry
I found solution on my own. Hope this will help someone. Here is the solution.
///I created an enum for list of metrics that facebook is providing
public enum FacebookMatricType
{
page_active_users,
page_active_users_locale
}
//Created a list of Facebook batch request for each metric using LINQ to Object and //concatenate string using string.format method.
var batchParameters = (from FacebookMatricType matricType in Enum.GetValues(typeof (FacebookMatricType))
select new object[]
{
pPageAccessToken,"insights",matricType.ToString(),pFromDate.Date.ToString("yyyy-MM-dd"),pPageId
}
into objectParamter
select new FacebookBatchParameter
{
HttpMethod = HttpMethod.Get,
Path =
string.Format(
"https://graph.facebook.com/{0}/{1}/{2}?since={3}&access_token={4}",
objectParamter)
}).ToList();
//Once I get the list of request I execute it using facebook web client using C# SDK.
var facebookClient = new FacebookClient(pProfileAccessToken);
var results = facebookClient.Batch(batchParameters.ToArray());
//Results are ready to deserialize.
Thank you. ;)
Dharmendra Mistry