Azure pipeline API call gate success criteria evaluation - json

In my azure pipeline I have a post release gate that I want to call my API to make sure it was deployed and is returning values that I expect.
I have added the service connection and am able to get a response from the API, but I am unsure how to evaluate the response, which is just an array of values :
["ACURA","ALFA ROMEO","AUDI","BMW","BUICK"]
How to I first check that the call was successful, and secondly check the existence of "AUDI" in the return values?

I think you could add a new stage which under your current stage.
When you current stage's Deployment Gate uses Invoke REST API task to response the values, as long as the new stage runs, the API call is sure to have succeeded.
To check the value, use Postman to get the returned values of the api.

Related

SSIS Error : oData VS_NEEDSNEWMETADATA Error When No Data Returned

I searched but didn't find anything specific to the issue I was having. My apologies if I overlooked it.
I have a scenario where I'm pulling data from an oData source and everything works fine. I have the oData source in a loop where I loop over each of our different companies and pull the data for that company. I'm doing this to reduce the volume of data that is being returned in each oData call.
Everything works fine as long as there is data being returned from the oData call. In the attached photo you can see that the call is being made and data is being returned.
But when the oData Service is called with parameters/filters that return no data I get the following and that is when the VS_NEEDSNEWMETADATA error is thrown. The image below shows what I get when no data is returned.
So the issue isn't that I have invalid metadata due to changes made to the service (adding/removing fields). It's that nothing is being returned so there is no Metadata. Now it's possible that this is an issue with the system that I'm pulling the oData from (SAP S4) and they way that system surfaces the oData call when there is no data??
Either way, trying to figure out a way to handle this within SSIS. I tried to set validate external metadata = false but the package still fails. I could also fix this by excluding those companies in the script but then once data does exists I'd have to remember to update the scripts and redeploy.
Ideas suggestions?
You've hit the nail on the head except your metadata is changing in the no data case because the shape is different - at least from the SSIS engine perspective.
You basically need to double invoke the OData source. First invocation will simply identify is data returned. If that evaluation is true, only then does the Data Flow start running.
How can you evaluate whether your OData will return data? You're likely looking at a Script Task and C#/VB.NET and hopefully the SAP data returns don't vary between this call and next call.
If that's the case, then you need to define an OnError event handler for the Data Flow, mark the System scoped variable Propagate to False and maybe even force a success status to be returned to get the loop to continue.

Azure Logic Apps - Verify content in JSON file

I have a logic app that runs as follows:
Step 1 = Recurrence (the schedule for the logic app to run)
Step 2 = HTTP (Performing a POST call on a custom API that returns a JSON file)
Step 3 = Create Blob (which uploads said document from Step 2 and uploads it to blob storage)
What I would like to do now is add an extra step between Step 2 and Step 3. After making the HTTP POST call, I would like to verify the content inside the JSON file that gets returned. If there is an error present in the JSON file, I want the Logic App to stop there.
Is there a particular step that I can use in Azure's Logic App to verify the data and have that step decide if it should continue on or not.
For this requirement, you can refer to my logic app below:
1. I initialize a variable named "resultFromHTTP" to simulate the json from your HTTP request(step 2). And I delete some character, so the "resultFromHTTP" is not a valid json format.
2. Then I initialize another variable and use the expression json(variables('resultFromHTTP')) in its value.
3. Run the logic app, it will fail and show error message like below screenshot. If the json is in valid format, it will run success.
===============================Update==============================
For your latest question, if the result json from HTTP request is not in valid json format and not a very long string, you can do it like this:
The contains(... expression is contains(variables('resultFromHTTP'), 'Data Not Found'). Then you can do what you want under "if true" or "if false".
If the result json from HTTP request is in valid json format, you can use "Parse JSON" action to parse it and get the specified field and then judge if it equals to "Data Not Found".

Enforce Json schema validation, on rest endpoint, to verify the integrity of Json response

Working on developing rest endpoint, with spring-boot, to consume a resource from another microservice (external), since both the services are in development phases, there is quite a lot of changes in request and response frequently. Many times our micro-service failed because of change in response from the target microservice.
To avoid this failure, we thought of Defining a JSON schema in the calling client to describe the expected response.
If there is a schema mismatch log an error message, prefixed with "JSON_SCHEMA_MISMATCH".
Please advise if there are any other better solutions for handling this in a more generic way, meaning the same could be used for other microservices as well without more duplicated codes.
You can use objects to directly fetch the values from the services.
For example -
VOClass vOobject = restTemplate.getForObject(url, VOClass.class, params);
The microservice which you are using should also return the same object, or the json with same variable names.
If there are variables you are getting in response match the variables from your VOClass object then those values will be set and those not matching will be null.
ALso if there are new varaibles returned from microservice, you can cosume them by adding those variables in your VOClass.

JSON Schema validation on HTTP Webhook callback url (Azure Logic Apps)

Within Azure Logic Apps, is there any way to use JSON Schema validation on the HTTP Webhook callback body? Similarly to how JSON Schema is used on the HTTP Trigger "When a HTTP request is received".
Directly, it does not seem so.
A possible alternative would be to use a Parse JSON component afterwards, but that would not throw a HTTP error when calling the callback url.
Are there any other possible solutions?
Currently, there is no option to do it directly on the Webhook callback. What you can do is to have an intermediate validator HTTP triggered Logic App (Webhook callback wrapper), that does the validation and then forwards the HTTP call to the actual Webhook callback only if valid.
To implement this, you would need to derive a new callback url that points to the intermediate validator Logic App, passing the instanceid in the CallbackUrl. Then you would need to reconstruct the full callback url at the wrapper logic app to forward the validated payload to the original Logic App instance.
You can get some insights on how to implement this Webhook callback wrapper in this post. In your case, as long as you can derive the original callback url on your wrapper/validator, you wouldn't need to store any correlation.
HTH.

String[] Input for REST Calls

I am new to REST Programming. I have a requirement to automate the working of an appliance which requires me to login to the appliance, use the auth token and perform other rest calls on the appliance subsequently. I have been able to login and perform routine GET calls and parse the output of the REST calls.
Now, the specification of the REST call that I am unable to understand is as following:
Call: PUT /rest/os-deployment-build-plans/<osbp-id>/run
Input: Std headers, String[] serverIds
Basically, this call is used to run a build plan against a server, I am unable to figure out how to give the String array as input. All the calls in this appliance take only JSON as input and accept only JSON types. Any pointers as to what this might mean? Is it a JSON string? Is it an array of JSON objects?