-1

The requested VM tier is currently not available in Southeast Asia for this subscription. Please try another tier or deploy to a different location

here is my api code:

using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Net.Http; using System.Web; using System.Web.Http; using System.Web.Mvc; using System.Linq.Expressions; using System.Windows.Media.Imaging; using System.IO; using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Binary; using SourceAFIS.Simple; // import namespace SourceAFIS.Simple using System.Drawing; using System.ComponentModel; using System.Net; namespace MvcApplication2.Controllers { public class ValuesController : ApiController { static AfisEngine AFIS = new AfisEngine(); static Person DatabasePersons = new Person(); static Person CandidatePerson = new Person(); static Fingerprint DatabaseFingerprints = new Fingerprint(); static Fingerprint CanditateFingerprint = new Fingerprint(); // Inherit from Fingerprint in order to add Filename field [Serializable] class MyFingerprint : Fingerprint { public string Filename; }

    // Inherit from Person in order to add Name field
    [Serializable]
    class MyPerson : Person
    {
        public string Name;
    }

    // Initialize path to images
    static readonly string ImagePath = Path.Combine(Path.Combine("..", ".."), "images");

    // Shared AfisEngine instance (cannot be shared between different threads though)
    static AfisEngine Afis;

    // Take fingerprint image file and create Person object from the image
    static MyPerson Enroll(string filename, string name)
    {
        Console.WriteLine("Enrolling {0}...", name);

        // Initialize empty fingerprint object and set properties
        MyFingerprint fp = new MyFingerprint();
        fp.Filename = filename;
        // Load image from the file
        Console.WriteLine(" Loading image from {0}...", filename);
        BitmapImage image = new BitmapImage(new Uri(filename, UriKind.RelativeOrAbsolute));
        fp.AsBitmapSource = image;
        // Above update of fp.AsBitmapSource initialized also raw image in fp.Image
        // Check raw image dimensions, Y axis is first, X axis is second
        Console.WriteLine(" Image size = {0} x {1} (width x height)", fp.Image.GetLength(1), fp.Image.GetLength(0));

        // Initialize empty person object and set its properties
        MyPerson person = new MyPerson();
        person.Name = name;
        // Add fingerprint to the person
        person.Fingerprints.Add(fp);

        // Execute extraction in order to initialize fp.Template
        Console.WriteLine(" Extracting template...");
        Afis.Extract(person);
        // Check template size
        Console.WriteLine(" Template size = {0} bytes", fp.Template.Length);

        return person;
    }

    public HttpResponseMessage Post()
    {
        ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
        var httpRequest = HttpContext.Current.Request;
        var a = httpRequest.Form.GetValues(0);
        Console.WriteLine(a);
        if (httpRequest.Files.Count < 1)
        {
            return Request.CreateResponse(HttpStatusCode.BadRequest);
        }
        System.IO.Stream fs = httpRequest.Files[0].InputStream;
        System.IO.BinaryReader br=new System.IO.BinaryReader(fs);
        Byte[] bytes = br.ReadBytes((Int32)fs.Length);
        TypeConverter tc = TypeDescriptor.GetConverter(typeof(Bitmap));
        Bitmap bitmap1 = (Bitmap)tc.ConvertFrom(bytes);
        DatabaseFingerprints.AsBitmap = new Bitmap(bitmap1);
        DatabasePersons.Fingerprints.Add(DatabaseFingerprints);

        var wc = new WebClient();
        var imgStream = new MemoryStream(wc.DownloadData((a[0])));
           
        System.IO.BinaryReader br1 = new System.IO.BinaryReader(imgStream);
        Byte[] bytes1 = br1.ReadBytes((Int32)imgStream.Length);
        TypeConverter tc1 = TypeDescriptor.GetConverter(typeof(Bitmap));
        Bitmap bitmap2 = (Bitmap)tc1.ConvertFrom(bytes1);
        CanditateFingerprint.AsBitmap = new Bitmap(bitmap2);
        CandidatePerson.Fingerprints.Add(CanditateFingerprint);

        // Extracting skeletons of database fingerprints and candidate fingerprint.
        AFIS.Extract(DatabasePersons);
        AFIS.Extract(CandidatePerson);

        // Matching
        bool res = false;
        float score = AFIS.Verify(CandidatePerson, DatabasePersons);

        bool match = (score > 40);
        int points = Convert.ToInt32(score);

        if (match)
        {
            Console.WriteLine(string.Format("Fingerprint match with {0} points", points.ToString()));
            res = true;
        }
        else
        {
            Console.WriteLine(string.Format("Fingerprint does not match with {0} points", points.ToString()));
            res = false;
        }
        return Request.CreateResponse(HttpStatusCode.Created,res);
   
    }
  
}

}

1 Answers1

0

This has nothing to do with your code, you are trying to create a VM size that is not available in the region you have selected. You need to change the VM Size or region to one that is available.

Sam Cogan
  • 38,736
  • 6
  • 78
  • 114