Posts

Showing posts from 2024

Missing Functions App in API Management Service in Azure

Image
When we go to add an Azure Function as an API in the API Managagement in Azure, some Azure Functions might be missing from the list and there is no filter screen in API Management Screen to see all the Azure Functions. In order to see all the functions, 1. Click on the gear icon on the top right of the screen. 2. Click on the Default Subscription Filter dropdown and make sure that you have the subscription(s) selected which have the Azure Functions. 3. Head back to to the API Management Screen and when you click on the Function API tile, you should be able to see the missing Azure Functions.

Creating a C# class from JSON.

Image
Previously to create a C# class from JSON, we would use some tool, either web based or otherwise to generate the C# class. Now we have an option to generate an C# class directly from Visual Studio using the menu option Edit --> Paste Special --> Paste JSON as Classes. Steps to implement this. 1. Copy the JSON that we to use to generate the C# class 2. Create a new C# class 2. Click on the menu option Edit --> Paste Special --> Paste JSON as Classes 3. We can see the C# class created. You might have to change some of the data types as at times, the date and integer properties are generated as string. Hope this helps.

Using IOptions class in .Net Core Unit Testing.

When implementing unit testng for a interface that was using a IOptions class, we were getting an null exception when trying to access the value using _mockMyconfig!.Object.Value . To resolve this error this, you have to manually create the MyConfig class and then assign it to the Value property. MyConfig myConfig = new MyConfig() { BaseURL = "https://mocktest.com" }; _mockMyconfig = new Mock >(MockBehavior.Loose); // We need to set the Value of IOptions to be the Myconfig Class, if this step is not done, then we get null exception when we try to use the value like this _mockMyconfig!.Object.Value _mockMyconfig.Setup(ap => ap.Value).Returns(myConfig); Once you have done this, then we use this in the unit testing like without getting the null exception. _mockHttpClient!.Setup(repo => repo.GetPWSHttpClient(_mockMyconfig!.Object.Value)).Returns(new HttpClient()).Verifiable(); The Main NuGet packages that have been used for th...

Retrieve Inbound IP Address for a Azure App Service when using a Private Endpoint.

When we are using Bicep Script to configure Azure App Services in your environment and we are using Private Endpoint, the Inbound IP Address of the Azure App Service is the Private IPv4 Address of the NIC associated with the Private Endpoint. Below is the Bicep script that we need to use to get the Private IPv4 IP address using the Bicep Script. // NICName - Replace the Nic Name with the name of the NIC from your environment. resource networkInterfacesResource 'Microsoft.Network/networkInterfaces@2023-09-01' existing = { name: NICName .nic' } //The IPv4 Address is part of the IP configuration of the NIC and the ipConfigurations is an array. Here in this example, we have only ipConfiguration associated with the NIC //so hard coding the array with the value 0 will work here. output IP string = networkInterfacesResource.properties.ipConfigurations[0].properties.privateIPAddress Just for completeness sake, below is the Bicep script that you can use to get the Inboun...