Is the CurrentRoleInstance.id permanent in deployed apps? - azure

I have a brief and simple question i think.. in the emulator the role id changes in every run. What about in a real azure deployment? After a restart of the vm does the role gets the same id?

If you look at the id for the deployed instances in the cloud, you'll find that they are always named in this fasion: [RoleName]_IN_[XXX] where XXX is a number depending on the number of instances deployed. So to answer your question, since the pattern for naming the instance is the same, I would say you'll get the same id. It's a different question if the VM represented by that instance id would be the same. There're 3 scenarios to cover:
A role instance is rebooted: If you reboot a particular instance, my guess is you will get the same instance id.
A role instance goes down: Though we don't really have an option of killing a specific instance thus we can't really test it, if a particular instance goes down and Azure stands up a new instance for you for that instance you would get the same instance id.
New deployment: If you do a brand new deployment (assuming with the same number of instances), you'll get the same deployment ids but the VM will be entirely different.

Related

Azure Kubernetes Service (AKS) and the primary node pool

Foreword
When you create a Kubernetes cluster on AKS you specify the type of VMs you want to use for your nodes (--node-vm-size). I read that you can't change this after you create the Kubernetes cluster, which would mean that you'd be scaling vertically instead of horizontally whenever you add resources.
However, you can create different node pools in an AKS cluster that use different types of VMs for your nodes. So, I thought, if you want to "change" the type of VM that you chose initially, maybe add a new node pool and remove the old one ("nodepool1")?
I tried that through the following steps:
Create a node pool named "stda1v2" with a VM type of "Standard_A1_v2"
Delete "nodepool1" (az aks nodepool delete --cluster-name ... -g ... -n nodepool1
Unfortunately I was met with Primary agentpool cannot be deleted.
Question
What is the purpose of the "primary agentpool" which cannot be deleted, and does it matter (a lot) what type of VM I choose when I create the AKS cluster (in a real world scenario)?
Can I create other node pools and let the primary one live its life? Will it cause trouble in the future if I have node pools that use larger VMs for its nodes but the primary one still using "Standard_A1_v2" for example?
Primary node pool is the first nodepool in the cluster and you cannot delete it, because its currently not supported. You can create and delete additional node pools and just let primary be as it is. It will not create any trouble.
For the primary node pool I suggest picking a VM size that makes more sense in a long run (since you cannot change it). B-series would be a good fit, since they are cheap and CPU\mem ratio is good for average workloads.
ps. You can always scale primary node pool to 0 nodes, cordon the node and shut it down. You will have to repeat this post upgrade, but otherwise it will work
It looks like this functionality was introduced around the time of your question, allowing you to add new system nodepools and delete old ones, including the initial nodepool. After encountering the same error message myself while trying to tidy up a cluster, I discovered I had to set another nodepool to a system type in order to delete the first.
There's more info about it here, but in short, Azure nodepools are split into two types ('modes' as they call it): System and User. When creating a single pool to begin with, it will be of a system type (favouring system pod scheduling -- so it might be good to have a dedicated pool of a node or two for system use, then a second user nodepool for the actual app pods).
So if you wish to delete your only system pool, you need to first create another nodepool with the --mode switch set to 'system' (with your preferred VM size etc.), then you'll be able to delete the first (and nodepool modes can't be changed after the fact, only on creation).

How to retrieve App Service Plan instance name (RDXXXXX)?

I am having an issue trying to retrieve all the instance names in an Azure App Service Plan.
In Azure Monitor, if you specify a "Scope" to "App Service Plan" and look at the Metric "CPU Percentage" and then add a filter to specify the "Instance" property, you can see which instance uses the most CPU. I am trying to do a PowerShell script to get these values. Unfortunatly I have not found any Azure REST Api that would give me this information so that my script would be 100% dynamic. I looked at the AzureRm or Az PowerShell modules but did not find anything there.
Any ideas how I can retrieve this list? The instances names looks like this :RD123456.
Thanks for you help !
Suppose you want to get the web instance name, if that's right you could get it from instance process with Web Apps - Get Instance Process.
And under the environment_variables there is a COMPUTERNAME suppose this is what you want.

Deploy azure functions across resource groups

I have looked at the Azure functions documentation but couldn't quit find answer to my question and hence I thought I asked the wider user community.
We have a single Azure subscription with multiple resource groups for our different environments, so one group for dev, one for test and one for prod.
We have developed multiple Azure functions in dev and would like to use CI/CD to deploy to test and prod.
However, doing this manually Azure complains that the name of the function app already exists which is weird because that would imply that the function app name must be unique to the subscription or globally across Azure? Does that mean you need to name your function apps func-dev, func-test etc? That seems very ugly.
How have you managed to solve this?
azure function name has to be globally unique (not just in your subscription), because the name would be like:
functionName.azurewebsites.net
so you cannot have a function with name functionName if you already created one, because the dns name for that is occupied.
you can use subfunctions to work around that, so create a subfunction called dev, test, and prod inside the function and call those
Function App, as any App Service application, has to have globally unique name:
Naming Conventions -> Compute.
Indeed, it's typical to include your environment into the App name.
Function names have to be unique within a single Function App, but may repeat in different apps.

Can i put vm into another resource group than availabilitySet?

I would like to keep each VM in separate resource group for ease for lifecycle management. I have a cluster containing n VLMs.
So I create one resource group for common things like public IP, load balancer and put availabilitySet declaration into it because is also must be shared between VMs.
Then I create VM in separate resource group and reference to availabilitySet with
"availabilitySet": {
"id": "[resourceId('Microsoft.Compute/availabilitySets',variables('availabilitySetName'))]"
},
Of cause 'availabilitySetName' is defined.
When I deploy my template I get an error saying
{"error":{"code":"BadRequest","message":"Entity resourceGroupName in resource reference id /subscriptions/a719381f-1fa0-4b06-8e29-ad6ea7d3c90b/resourceGroups/TB_PIP_OPSRV_UAT/providers/Microsoft.Compute/availabilitySets/tb_avlbs_opsrv_uat is invalid."}}
I double checked that resource and availability set name are specified correctly.
Does it mean that I can't put a set in separate resource group from VM?
Unfortunately, having a VM use an availabilitySet in a different resource group is not supported :(.
First of all, let me ask you why you want different resource groups? I strongly believe that you're overthinking it with multiple resource groups. A resource group is basically your "Entire System" and within the boundaries of one solution, you should only have one resource group for production, one for beta/staging etc, but never mix.
If you're selling SaaS to your customers it would make sense to have one resource group for each of your customers.
And as you know, a Resource group is simply a way for you to link together and manage all of the assets in your solution; vm's, storage, databases etc under one common name. I am very doubtful as to why one would want to consider multiple resource groups in a single solution, however, I am always willing to learn :)
Availability groups
Now, Availability groups are a different thing. This has to do with "Update Domains" and "Fault Domains" for your VM instances. Because Azure does not keep 3 separate VM's for you, as it does with most of it's PaaS services, you have to manage these yourself to ensure full uptime. Basically, when you're adding two or more VM's in an Availability Set, you're ensured that planned or unplanned events, at least one of the VM's will be available to meet the SLA.
Trying to combine the two in an effort of preventing downtime may sound like a good idea, but it is not solving any problems that I'm aware of. Like the old saying goes: if it aint broke, don't fix it :)

Getting Azure VM Instance ID from within a VM and linking it with imported Azure VM instances

I am developing a client-server application where I want the client (Azure VM) to send its instance ID to the server. The server will use this instance ID to link it with the corresponding VM from the list of imported Azure instances (using Azure cloud credentials).
I am facing some problems:
I am using the web endpoint which the client talks to , to get its instance ID. However, as mentioned in the article (https://azure.microsoft.com/en-us/blog/what-just-happened-to-my-vm-in-vm-metadata-service/), I get empty info returned. How do I get the instance ID?
From the imported VMs, I don't get any attribute which is the instance ID but rather just instance Name and Private ID along with a bunch of other information.
I didn't have this problem for AWS as I clearly get instance ID on both sides.
Maybe you could use something like:
curl -H Metadata:true "http://169.254.169.254/metadata/instance/compute/vmId?api-version=2017-08-01&format=text"
As described here:
https://learn.microsoft.com/en-us/azure/virtual-machines/windows/instance-metadata-service
Which instance ID is this? (i.e. how do you get the list of ID's and what is their format?) Is it the one mentioned in the article below? If so, then the article below shows how to get it :).
https://azure.microsoft.com/en-us/blog/accessing-and-using-azure-vm-unique-id/
How are You acquiring this data, by means of which tools (xPlat Cli, PowerShell, MAML, REST API...?) maybe look here too https://azure.microsoft.com/en-us/blog/accessing-and-using-azure-vm-unique-id/

Resources