How to get number of cores of VM in azure [closed] - c#

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I am trying to find an api or Microsoft inbuilt functions which can help me retrieve the number of cores in a particular VM

Unfortunately there's no straight forward way to get this information.
As far as REST API go, you would need to make 2 API calls:
Get Virtual Machine: First API you would need to call is get the details about your VM using Virtual Machines - Get. The properties that are of interest to you are the location of the VM and VM Size Type.
Get Resource SKU: This is the next API you would need to call using Resource Skus - List. This will give you the details about all the VM SKUs. Now this is going to be a very long list and unfortunately very limited filtering capability is available (at least at the time of answering this question). Only filtering capability available is that by location (that's why getting location information in the 1st step is important).
Once you get the list of all available SKUs, you will need to first filter out by resourceTypes where the value is virtualMachines and name where the value is the VM Size Type obtained in the 1st step.
Once you do that, the number of cores can be obtained in vCPUs attribute under capabilities property.

Here you go:
GET https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/vmSizes?api-version=2019-07-01
edit: if you need it for the running VM you need to get the hardware profile of the VM and use that first call to determine the number of cores. But its kinda static, so you might as well hardcore the results

Related

Getting Wifi RSSI or signal strength using WlanAPI and IpHlpAPI [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 24 days ago.
Improve this question
I'm trying to recreate the functionality of the wifi icon inside the Windows task bar using this library and C#.
https://github.com/dahall/Vanara
To get the current network interface I am calling GetBestInterface from IpHlpAPI and it seems to be returning the right index. However I'm struggling on how to get the RSSI or signal strength value of the wifi network that's attached to this interface. Using this data I could recreate the wifi icon with 1 bars, 2 bars, 3 bars, ect..
Using WlanAPI I can call WlanGetAvailableNetworkList which returns a list that has the signal strength value for each network. There doesn't seem to be any data to connect these two things, so obviously I'm missing something.
Anyone have any ideas on the approach I should take?
You could try to use WlanQueryInterface function with wlan_intf_opcode_current_connection to query various parameters of a specified interface. You could get a percentage value that represents the signal quality of the network from WLAN_ASSOCIATION_ATTRIBUTES structure.

How to load data from mysql db on start up .Net Core Web API service application? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 26 days ago.
Improve this question
I am new to .Net Core and MySql.
I am trying to develop an service application which would provides multiple types of data to other applications via REST api call using .Net Core and MySql.
I am not able to figure out how to load all the data at start of the application, so that when api calls are triggered, the response can be generated with the data already loaded in the application instead of fetching it from database for each request.
Please suggest an efficient way to achieve this.
I would solve it by using a class that handles the connection to the database and then you have methods for each way you want to access data. Then on the first fetch you collect the data you need from the database and then cache it for the next call. That way you don't need to keep everything in memory if you don't need it.
But if you really need full speed preloading (if possible) is the way to go. Then it depends much of how your data i structured. I would probably load all data into classes so they are already in the correct format and then use a dictionary with the appropriate keys to get the data out of the dictionary. The problem will be if it will be possible to get data in many different ways. If you have database with persons you could create a Person class with all the information about the person and then use the email as the unique identifier so when your other application want all info of a Person by using email a dictionary will be superfast. But if you also want to get all persons in a city or with a specific first name the dictionary will be slow since you will have to loop through all items to look for the city or name.
I would put in my time on how all the searches will be and if you have an id as a unique identifier of a person you could use that in the dictionary and then use a seperate dictionary for each search. So one dictionary where the key is the email and the value points to the unique id in the dictionary with all users. And then another dictionary for cities where the dictionary contains a list of all ids of persons in that city and so forth. In this way you are creating a kind of index like the database uses to fetch data fast.
But it really depends on your data. Is it very complex. Are there a lot of items in the database? Are there a lot of tables which will have there own searches? Can you search for the items in many ways? Will it be allowed to search using wildcards?
The problem is that you are trying to create a temporary in-memory database using the real database as a starting point. And it's not possible to ask someone which is the most efficient way to create a database. To be able to answer that you will need more info.
If you need even more speed you could also pre-serialize all responses and keep them as strings so you can send json (or which format you now will use) straight away. The problem is the more speed you need the more "ugly" the code will get and you will pay for it in memory consumption.

C# Scrape a website then convert to JSON [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
This may possibly be a broad question however I'll try to make it as specific as possible.
I have created a store type application which lists Minecraft mods. The way I currently store the information for the store is in a .json file where different variables are declared for my application to read and list them into a listbox.
However, the issue here being obvious is that I would have to manually update this .json file whenever I needed to add new mods or update them. I'm wondering if it's even possible to scrape a website such as spigotmc.org for all of its downloads, and grab the following information from them.
{
"productName": "SupplyDrop",
"category": "Chat",
"version": "4.6",
"minecraftVersions": ["1.8", "1.9"],
"API": ["CraftBukkit", "Spigot"],
"downloadLink": "https://www.spigotmc.org/resources/supplydrop-1-8-1-9.23455/download?version=90759",
"spigotLink": "https://www.spigotmc.org/resources/supplydrop-1-8-1-9.23455/",
"description": "Supply Drop is a very useful plugin for any survival server, especially factions servers. What it does is it randomly drops a chest around the map that contains items in it, for one player to find and receive!",
"imageLink": "https://www.spigotmc.org/data/resource_icons/23/23455.jpg",
"longDescription": "Supply Drop is a very useful plugin for any survival server, especially factions servers. What it does is it randomly drops a chest around the map that contains items in it, for one player to find and receive! This plugin can bring the competitiveness out in your players as they compete for the chest!"
}
This is how individual items are stored in the file.
As said, if possible I'd like to be able to automatically scrape a website such as spigotmc.org for all of the mods and get information and translate it to this system.
Is this even remotely possible?
If you just need the data, you could use a web Scraper tool like Outwit , Import.io , Kimono.
Or if you need to develop on your own, you could use Regex, HtmlAgilityPack.
you can also have a look at the Articles, which may help you.

badges / achievements [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
i'm looking to implement a similar thing to stackoverflow badges. you could also equate them to achievements in games.
but am not sure how to design the database/code/tracking for them.
i get what i should do for badges such as:
Altruist × 1456 First bounty you manually awarded on another person's question
because they are a one time event, but how to handle others such as:
Analytical × 16389 Visited every section of the FAQ
Electorate × 1783 Voted on 600 questions and 25% or more of total votes are on questions
Outspoken × 188 Posted 10 messages in chat that were starred by 10 different users
etc...
how to handle them, how to keep track of progress for each, etc... is there a tutorial or something that can help me figure out a design pattern for them?
For the given examples, there are essentially two mechanisms you are going to need.
I don't know how it's done on SO, this is just a suggestion of a solution.
Let's look at 'Analytical' first. You are going to have to record by means of a simple flag when a user visits a particular area in the FAQ. Let's envisage a DB table with a field for each FAQ section and a user ID. This starts off as "N" (or 0, or however you want to represent your flag). When a user visits that area, you call code to flip that field to "Y". When all fields are "Y" then you can award that badge.
As for 'electorate' and 'Outspoken', you can retrieve this information by means of a query on your existing data, assuming the queries themseves are not too burdensome. You are going to need to consider when to run these checks. This essentially boils down to two options.
1) When the an action is performed that might get a badge awarded (i.e. visit section of FAQ, Vote on a Question, Question starred by someone else)
2) Periodically (hourly, daily, etc) run a check for all your badges against current data.
Bear in mind that badges are one-way in Stackoverflow, so if you are wanting to be equivalent then you don't have to consider logic to 'un-award' badges.

What is the best way to represent a large field of objects while using minimal resources? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
all I am looking to develop a project in unity, it is for android! I was wondering if I could get some clarity on a few things. My problem involves me trying to creating a universe of stars, 150,000 individual stars to be exact, granted there would only be a certain percentage in view at any one time. What is the most efficient structure for being able to convince the user of a realistic environment while keeping the overhead to a minimum since it will be on a phone?
What type of objects do I want to use to represent the masses of stars vs. the likes of stars in close proximity that require finer details?
What sort of threading structures should I consider while planning this project?
How easily does a project port from unity to android, in such scenarios?
Any help is much appreciated as I am looking to better develop with unity, cheers
I would suggest not tracking all 150,000 stars, but only the ones that are in view. When the field of view changes, use a random number generator to define the stars that have just entered it, and drop from memory the ones that have left. To preserve consistency, you might want to retain the stars for a short period around the current field of view, if the user can do rapid switches in direction.
As for threading, that's less a function of the number of stars you are tracking, and more a function of what it is that you are doing with them - something you didn't mention.
1) This question is mainly a game development question and not unity regarding. I just point you in the direction, as a complete answer would be to much. Normally if you need to know where you are in a 3D scene with infinite objects or close (150k is close), you would use a octree for orientation. Constructed like a map, each node of the tree points a direction (West, South, Nord, East, NNW, ...) Then you each of your stars gets 1 node, and you can calculate what is where and how much do you want to see. More information can be found on google. (Quite complicated topic jfyi)
2) Dedicated to 1) with a mix of entity/component design. You will know what I mean after 1) is clear to you.
3) Absolutly Multithreaded Asynchron. 1 Thread Update, 1 Thread Draw, Few Worker Threads (position, ...)
4) The port of Unity Engine is actually working really good. Of course you should have an android peripherial to test and debug on, but most of the time, it will work for you.

Categories