CognitiveServices.Face endpoint returns null in Visual Studio

Egling 21 Reputation points
2020-10-10T21:23:49.883+00:00

Following this tutorial:
https://learn.microsoft.com/en-us/azure/cognitive-services/face/tutorials/faceapiincsharptutorial

The following line returns null.
private static string faceEndpoint = Environment.GetEnvironmentVariable("https://pocfacerec.cognitiveservices.azure.com/");

31350-22capture.png

I have tried the following:

  1. Regenerating the keys.
  2. Using a new CognitiveServices.Face resurces in a different location.

I have tested my visual studio and I am able to make outbound connections. Please help.

Azure Face
Azure Face
An Azure service that provides artificial intelligence algorithms that detect, recognize, and analyze human faces in images.
155 questions
Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
2,615 questions
0 comments No comments
{count} votes

Accepted answer
  1. romungi-MSFT 43,686 Reputation points Microsoft Employee
    2020-10-12T10:39:59.143+00:00

    @Egling From the sample it looks like you are using the resource endpoint as the variable to be read in the code. Ideally you would set an environment variable on your machine and then reference it in your application code. Here are the steps of setting and retrieving the environment variable in detail.

    For example set a variable using this powershell command.

    [System.Environment]::SetEnvironmentVariable('ENVIRONMENT_VARIABLE_KEY', 'value', 'User')  
    

    Retrieve it using the same ENVIRONMENT_VARIABLE_KEY, It should not be the value as it is currently used in your application. The variable my_value will hold the value of your endpoint or key.

    using static System.Environment;  
      
    class Program  
    {  
        static void Main()  
        {  
            // Get the named env var, and assign it to the value variable  
            var my_value =  
                GetEnvironmentVariable(  
                    "ENVIRONMENT_VARIABLE_KEY");  
        }  
    }  
    

    I hope this helps.


0 additional answers

Sort by: Most helpful