- C# 7
- .NET Standard 2.0, .NET Core 2.0
- Azure Blob Storage
- Azure Functions v2.0 Beta
- Encode the two binaries that you need to compare as Base64 string.
- Put these Base64 strings to JSON into
data
field. - Pick an
ID
for the comparison. - Send the binaries with
PUT
request to/v1/diff/:id/left
and/v1/diff/:id/right
URLs. - Receive the comparison result with
GET
request to/v1/diff/:id
URL.
A test version of this application is deployed to https://binarycompare.azurewebsites.net
base URL.
Upload binary as left
or right
object for comparison.
-
URL
/v1/diff/:id/left
and/v1/diff/:id/right
-
Method:
PUT
-
URL Params
id=[string]
- difference ID that you pick, to be used when requesting the difference -
Content
{ "data": "<base64 encoded binary>" }
-
Success Response:
- Code: 200
Binary was uploaded successfully
- Code: 200
-
Error Response:
- Code: 404 NOT FOUND
URL is not correct
OR
- Code: 400 BAD REQUEST
Missing or invaliddata
parameter in the request body
Content:"Reason explaining why the request was not valid"
- Code: 404 NOT FOUND
-
Sample HTTP Request:
PUT /v1/diff/sampleid/left HTTP/1.1 Content-Type:application/json Accept:application/json {"data":"AQIDBAUGBwgJAA=="}
Get the comparison result of 2 previously uploaded binaries (left and right).
-
URL
/v1/diff/:id
-
Method:
GET
-
URL Params
id=[string]
- difference ID, which was used to upload the two binaries to compare -
Success Response:
- Code: 200
Comparison is successful
Content when binaries are exactly the same:
{"result":"same"}
Content when binaries have different length:
{"result":"size-differs"}
Content when binaries have the same length but some differences exist (example):Both{ "result":"different", "differences": [ { "startIndex": 5, "length": 2 }, { "startIndex": 11, "length": 1 } ] }`
startIndex
andlength
refer to each byte separately.
- Code: 200
-
Error Response:
- Code: 404 NOT FOUND
One or both binaries with requested ID were not uploaded yet
- Code: 404 NOT FOUND
-
Sample HTTP Request:
GET /v1/diff/sampleid HTTP/1.1 Content-Type:application/json Accept:application/json
- Make sure that you have a proper Azure Storage connection string in
local.settings.json
dotnet restore
to restore NuGet packagesdotnet build
to build the solutiondotnet publish
to publish the binariescd BinaryDiff
thenfunc start --script-root bin\\debug\\netstandard2.0\\publish
to start Function App locallydotnet test 'BinaryDiff.Tests\\BinaryDiff.Tests.csproj'
to run tests (Integration Test required Function App to be running)
If you are using Visual Studio Code, it has predefined commands for running Function App and Tests directly in editor's console.