示例#1
0
        static void Main(string[] args)
        {
            var remoteImageUrl = storagefunc();

            Console.WriteLine("Welcome to Face API at work ....!");
            MyKeys     mykey           = new MyKeys();
            string     subscriptionkey = mykey.Subscriptionkey;
            string     faceEndpoint    = mykey.FaceEndpoint;
            FaceClient faceClient      = new FaceClient(
                new ApiKeyServiceClientCredentials(subscriptionkey),
                new System.Net.Http.DelegatingHandler[] { });

            faceClient.Endpoint = faceEndpoint;
            Console.WriteLine("Face being detected . . .");
            var t1 = DetectedRemoteAsync(faceClient, remoteImageUrl);

            Task.WhenAll(t1).Wait(5000);
            Console.WriteLine("Press any key to exit");
            Console.ReadLine();
        }
示例#2
0
        private static string storagefunc()
        {
            // Retrieve the connection string for use with the application. The storage connection string is stored
            // in an environment variable on the machine running the application called storageconnectionstring.
            // If the environment variable is created after the application is launched in a console or with Visual
            // Studio, the shell or application needs to be closed and reloaded to take the environment variable into account.

            string storageConnectionString = "";
            MyKeys mykey = new MyKeys();

            storageConnectionString = mykey.StorageConnectionString;
            string primaryUri = "";
            // Check whether the connection string can be parsed.
            CloudStorageAccount storageAccount;

            if (CloudStorageAccount.TryParse(storageConnectionString, out storageAccount))
            {
                // If the connection string is valid, proceed with operations against Blob storage here.
                // List the blobs in the container.

                CloudBlobClient    blobClient = storageAccount.CreateCloudBlobClient();
                CloudBlobContainer container  = blobClient.GetContainerReference("takmil");
                CloudBlob          blob       = container.GetBlobReference("takmildemo.jpg");
                primaryUri = blob.StorageUri.PrimaryUri.ToString();
                Console.WriteLine(primaryUri);
                return(primaryUri);
            }
            else
            {
                // Otherwise, let the user know that they need to define the environment variable.
                Console.WriteLine(
                    "A connection string has not been defined in the system environment variables. " +
                    "Add an environment variable named 'storageconnectionstring' with your storage " +
                    "connection string as a value.");
                Console.WriteLine("Press any key to exit the sample application.");
                Console.ReadLine();
                return(null);
            }
        }