Create sample app with AutoRest
Creating a sample client app¶
In this tutorial we will walk through the steps necessarily to make a C#/.NET application that uses the Engine Execution API to start an execution.
To complete this tutorial for generating a client for the APIs, you will need:
- Node.js
- AutoRest
- Visual Studio 2019
You can find the final code here
Preparations¶
Node.js¶
Ensure that latest version of node.js is installed.
Verify that node.js is installed and ensure that version is 10.15.3 or newer by opening Windows PowerShell and executing command:
node -v
Also ensure that NPM version is 6.9.0 or newer by executing command:
npm -v
AutoRest¶
Install AutoRest from Windows PowerShell by executing command:
npm install -g autorest
or update existing AutoRest installation to the latest version by executing command:
autorest --latest
Create the sample app¶
Use following steps to create the sample application:
- Create an empty Visual Studio solution and give it the name EngineExecutionClient.
- Add class library with name EngineExecutionAPI
- Open the package manager, select EngineExecutionAPI project, and run this command:
Install-Package Microsoft.Rest.ClientRuntime.Azure -Version 3.3.19
After running the command you can see that the packages got installed.
Generate client using AutoRest¶
Open Windows PowerShell, change directory to your project directory and run the following commands (make sure the url is correct) to generate a client:
iwr "https://api.mike-cloud-test.com/swagger/v1/swagger.json" -o dhi-water-data-engine-api-v1.json
autorest --input-file=dhi-water-data-engine-api-v1.json --csharp --output-folder=. --namespace=EngineExecutionAPI