The publication can be made to an App Service, previously created using the portal, but in the next step we will see how to create the same without leaving Visual Studio.
To do this, it’s required to have an Azure subscription. If you don’t have it, you can create one test subscription of a month, in http://azure.microsoft.com/en-us/pricing/free-trial/. If you already have it, follow the next steps:
In Solution Explorer, right click in project and click Publish;
In the publish dialog, access the Profile panel and choose the option Microsoft Azure API Apps;
Click New to create a new API App in the subscription;
In the Create dialog, add:
The API App name. Here we will use MailApiService;
Select the disired subscription;
Pick a name to the App Service;
Pick a name to the Resource Group;
Choose the access level Available to Anyone;
Pick the region where you what to host the App Service.
Click OK and wait a few minutes while the service is being created. The creation request can be followed in the Azure App Service Activity panel;
Once the App Service is created, we go back to the step number 1, access the publish dialog, and we click in the Publish option;
The service will be published.
Consume na API from a .NET client.
Let’s see how to create an SDK to our API and use it.
Add a Console Application to our solution;
In the Solution Explorer, right click in the Console Application and select the option Add > Azure API App Client;
In the presented dialog, pick the option Download from Microsoft Azure API App and select the MailApiService, create previously;
Click OK and wait until the SDK is created;
When the last step is completed, we are ready to invoke our API, as the following code shows.
classProgram { staticvoidMain(string[] args) { var client =newMailApiService(); var data =newModels.MailModel{ To ="darth.vader@deathstar.com", Subject ="War Report", Body ="The Force awakens"};
With this new service created by Microsoft, we are able to provide features that in the past had a huge development cost, in an easy and quick way. The private gallery in conjunction with the easy way to consume APIs, provides the required capabilities to create an API ecosystem.