Just because this knowledge faded away as well over the past few months. It’s very easy to debug a custom API App if you keep a few gotchas in mind. Here is a simple stepping plan.
- Publish your API App to Azure. See the previous post. Make sure you deploy the API App with the Debug configuration (see Settings tab).
- Next create a new Console project and solution. For instance. The solution could be Client.DSP.DSPClient and the project DSPClient. As we’ll see later, it’s very important to create the testclient in a separate solution.
- Right-click the console application and select Add\REST API Client. The dialog is self explaining. Client code to consume the API App will be generated.
- Now move to file Program.cs to add code for calling the client. In this case I had to pass the contents of a XML file. As an example see the code below.
- Now go to the solution with your custom API App. On the left hand side in Visual Studio, you will see the Server Explorer. Select the Azure node, select App Service. Select the resource group and your custom API App. Right-click the custom API App and select Attach Debugger. The API App will be started now. You can add breakpoints.
- Now go to the client project. Set a breakpoint and press <F5>. Now you can start debugging.
Example code test client:
class Program
{
static void Main(string[] args)
{
var client = new DSPConnector();
string path = @”C:\Test\AGAssetsAHak.xml”;
string AGA_xmlstring = File.ReadAllText(path);
string result = client.PostAGAssets(AGA_xmlstring);
}
}