Unable to deploy Azure Function with Premium Service Plan - azure

When I try to create a FunctionApp Premium Plan using the following commands:
# Create a Resource Group
az group create \
--name $rg_name \
--location $az_loc
# Create a Function App Storage Account
az storage account create \
--name $fa_storage_name \
--resource-group $rg_name \
--location $az_loc \
--sku Standard_LRS
# Create a Premium plan
az functionapp plan create \
--name $fap_name \
--resource-group $rg_name \
--location $az_loc \
--sku P2v2
I receive an error:
The requested app service plan cannot be created in the current
resource group because it is hosting Linux apps. Please choose a
different resource group or create a new one.
I also tried the sku EP2 with same result. The SKU's are really hard to find in the docs(!). Does anyone know which sku's work with Linux Azure Functions and what I might be missing here?

This is common error.
The solution is to create a new Resourse Group and put the function app in.
The problem comes from the conflict between azure function plan based on windows and based on linux.
Create a new Resource group is the only way, and notice to separate function based on linux and windows in your development.

Here is what ended up working for me. Note the --is-linux true flag in az functionapp plan create and the --plan flag in az functionapp create:
# Create a Premium plan
az functionapp plan create \
--name $fap_name \
--is-linux true \
--resource-group $rg_name \
--location $az_loc \
--sku EP2
# Create Function App (container for Azure Function)
#--consumption-plan-location $az_loc \
az functionapp create \
--name $fa_name \
--resource-group $rg_name \
--storage-account $fa_storage_name \
--plan $fap_name \
--os-type Linux \
--runtime python \
--runtime-version 3.7 \
--subscription $az_sub \
--functions-version 2

There is a current limitation where Windows and Linux apps cannot exist in the same resource group.
https://learn.microsoft.com/en-us/azure/app-service/containers/app-service-linux-intro#limitations
Therefore, it was failing when deploying a Windows resource and worked when --is-linux was set to true

Related

Creating vm using azure cli

I'm learning azure for 2 weeks now, I'm curious about creating vm on the cli. For example if I want to create a vm in a region with a specific size using cli, but it turns out that the size isn't available so I want the script to auto select another size with the same specs that I chose in the first place but I don't know how. This is my script now:
az group create --name TestingVM --location eastus
az vm create \
--resource-group TestingVM \
--name TestingVM \
--image Debian \
--admin-username aloha \
--size Standard_F8s_v2 \
--location eastus \
--admin-password *somepassword*
thanks!

Azure - cannot get "Network Profile"

my Admin in Azure with full permissions runs the command to retrieve the network profile ID with deployed Virtual Network and Subnet which we are using but the command always returns the empty response:
az network profile list --resource-group myResourceGroup \
--query [0].id --output tsv
It has permissions, resourceGroup value is correct what should be the case?
Why it gets empty response? It is really essential for us to retrieve this value.
The output should contain value in this format:
/subscriptions/<Subscription ID>/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkProfiles/aci-network-profile-aci-vnet-aci-subnet
Thank you
You could verify if you have deployed ACI in that VNet instead of only a standard VNet. When use az network profile, Currently, only Azure Container Instances are supported.
When you first use the az container create command to deploy a container group to a subnet (and thus a virtual network), Azure creates a network profile for you. You can then use that network profile for future deployments to the subnet.
For example, if you create a container group in a new VNet or an existing VNet referring to this.
az container create \
--name appcontainer \
--resource-group myResourceGroup \
--image mcr.microsoft.com/azuredocs/aci-helloworld \
--vnet aci-vnet \
--vnet-address-prefix 10.0.0.0/16 \
--subnet aci-subnet \
--subnet-address-prefix 10.0.0.0/24
Then you will list the network profile in that resource group.
Update
If you want to deploy a container in an existing VNet, you can deploy it like this with --vnet NAME --subnet NAME | --vnet ID --subnet NAME | --subnet ID:
az container create --name appcontainer --resource-group nancylab --image mcr.microsoft.com/azuredocs/aci-helloworld --vnet aci-vnet --subnet subnet1

Unable to add spot node pool to Azure Kubernetes Cluster

Unable to add spot node pool to Azure Kubernetes Cluster
AWS-CLI
azure-cli 2.12.0
core 2.12.0
telemetry 1.0.6
Extensions:
aks-preview 0.4.63
Following the instructions on Microsoft site: https://learn.microsoft.com/en-us/azure/aks/spot-node-pool
Ran the following
# Create a resource group in East US
az group create --name myResourceGroup --location westus2
# Create a basic single-node AKS cluster
az aks create \
--resource-group myResourceGroup \
--name myAKSCluster \
--vm-set-type VirtualMachineScaleSets \
--node-count 1 \
--generate-ssh-keys \
--load-balancer-sku standard
az aks get-credentials --resource-group myResourceGroup --name myAKSCluster
az aks nodepool add \
--resource-group myResourceGroup \
--cluster-name myAKSCluster \
--name spotnodepool \
--priority Spot \
--spot-max-price -1 \
--eviction-policy Delete \
--node-vm-size Standard_D2as_v4 \
--node-count 1
Got the following error:
Error code:
ValidationError: Operation failed with status: 'Bad Request'. Details: Provisioning of resource(s) for Agent Pool spotnodepool failed. Error: {
"code": "InvalidTemplateDeployment",
"message": "The template deployment failed with error: 'The resource with id: '/subscriptions/REDACTED/resourceGroups/MC_myResourceGroup_myAKSCluster_westus2/providers/Microsoft.Compute/virtualMachineScaleSets/aks-REDACTED-vmss' failed validation with message: 'The requested size for resource '/subscriptions/REDACTED/resourceGroups/MC_myResourceGroup_myAKSCluster_westus2/providers/Microsoft.Compute/virtualMachineScaleSets/aks-REDACTED-vmss' is currently not available in location 'westus2' zones '' for subscription 'REDACTED'. Please try another size or deploy to a different location or zones. See https://aka.ms/azureskunotavailable for details.'.'."
}
I have tried other AZ region, useast, uswest2, etc but with no luck
If I run the following it will work:
az aks nodepool add \
--resource-group myResourceGroup \
--cluster-name myAKSCluster \
--name mynodepool \
--node-count 1
Is spot node pool not supported? It is in the official docs: https://learn.microsoft.com/en-us/cli/azure/ext/aks-preview/aks/nodepool?view=azure-cli-latest
I just realised that this is not a AKS or Spot issue. This is a subscription issue.
In the docs (https://learn.microsoft.com/en-us/azure/virtual-machines/spot-vms#limitations) it says that only Pay-As-You-Go subscription are allowed to use spot instances. I just recently upgraded to Pay-As-You-Go model but my offerID is still stuck as "Free Trial" - I just need to be patient for it to change over

Programmatically Configure HTTPS Only for Azure Function App

Is there a way to programmatically enable the HTTPS Only flag on a custom domain of an Azure Function App? I've been using the CLI quite extensively and have been pleased with the comprehensive coverage it provides, but I can't seem to figure this out out.
Try the command as below.
az functionapp update --name '<function name>' --resource-group '<resource group name>' --set httpsOnly=true
Good news!
There is support for https-only=true in az functionapp create since az-cli version 2.41.0:
Documentation:
https://learn.microsoft.com/en-us/cli/azure/functionapp?view=azure-cli-latest#az-functionapp-create
Example of command:
az functionapp create \
--name $APPNAME \
--resource-group $RESOURCEGROUP \
--consumption-plan-location $LOCATION \
--storage-account $STORAGEACCOUNTNAME \
--app-insights-key $APPLICATIONINSIGHTS_INSTRUMENTATIONKEY \
--functions-version 4 \
--https-only true
After running the command you will get this in azure portal:

re-naming resources in Azure

Is there a way to rename resources in Azure? I create a VM and azure has created a number of resources with some unfriendly names. Specifically the NIC Azure named it Interlinkclone-nic-5a216a7b39ac47d3be6f9e6415221161, which is really a pain to type in the CLI.
I tried to create another NIC but I can find how to attach it the VM.
Currently, Azure does not support rename NIC. Please refer to this feedback.
But you could create NIC with specified name firstly, when you create VM then attach it to VM. You could use the following example.
##create NIC with specified name
az network nic create \
--resource-group myResourceGroup \
--name myNic \
--vnet-name myVnet \
--subnet mySubnet \
--public-ip-address myPublicIP \
--network-security-group myNetworkSecurityGroup
##create VM
az vm create \
--resource-group myResourceGroup \
--name myVM \
--location eastus \
--availability-set myAvailabilitySet \
--nics myNic \
--image UbuntuLTS \
--admin-username azureuser \
--generate-ssh-keys
More information about this please refer to this link.
If you want to add a new nic to your VM, you also could check this official document.

Resources