Im trying to create a Business Central container in Azure and am using the following in powershell.
$imageName = “mcr.microsoft.com/businesscentral:10.0.17763”
$resourceGroup = “d365rg”
$location = “EastUS”
$containerName = “d365bcdemo02”
$dnsName = “d365bcdemo02.eastus.azurecontainer.io”
$artifactUrl = Get-BCArtifactUrl -type sandbox -country us -select Latest
az container create -g $resourceGroup -n $containerName --image $imageName --os-type Windows --cpu 2
--memory 16 --ip-address public -e artifactUrl=$artifactUrl ACCEPT_EULA=Y USESSL=N ClickOnce=Y
publicDnsName=$dnsName --dns-name-label $containerName --ports 80 7046 7047 7048 7049 8080
But am constantly getting the error:
"az : The image 'mcr.microsoft.com/businesscentral:10.0.17763' in container group 'd365bcdemo02' is
not accessible. Please check the image and registry credential."
What credentials , i dont have a container registry and dont think you need one. What could be happening here ?
The issue is caused by the wrong image tag. So the solution is to use the tag available in the image.
Related
I want to use azure cli command to change the reference image of vmss and update the vm running under the vmss.
I used to use UI to update the reference image as shown below.
I tried following https://learn.microsoft.com/en-US/cli/azure/vmss?view=azure-cli-latest#az_vmss_update
but not getting exact command, am I going in wrong direction?
I have tested in my environment to change the reference images of VMSS but it seems not possible using below cmd.
Update-AzVmss ` -ResourceGroupName "myResourceGroup" ` -VMScaleSetName "myScaleSet" ` -ImageReferenceId /subscriptions/{subscriptionID}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/myNewImage
If you want to update the version of reference image you can change with the below command.
Update-AzVmss -ResourceGroupName "myResourceGroup" -VMScaleSetName "myScaleSet" -ImageReferenceVersion 16.04.201801090
This is the CLI command I have used
az vmss update --name MyScaleSet --resource-group MyResourceGroup --set virtualMachineProfile.storageProfile.imageReference.id=imageID
I have an Azure VMSS (Virtual Machine Scale Set) with a few instances, linked to an "image gallery". The VMSS is configured in such a way that it is supposed to always choose the latest version of a specific image from the image gallery.
How and where can I see, which version of the image is installed on a specific instance?
If the image gallery is configured to install the latest image on new instances, the image version can potentially vary between instances. The actually installed version of an image is stored in the storageProfile.imageReference.exactVersion property of the vmss object.
Listing the installed image version for a specific machine in an existing scale set:
az vmss show --resource-group "<resource group name>" \
--subscription "<subscription name>" \
--name <vmss name> \
--instance-id <instance id> \
--query storageProfile.imageReference.exactVersion
The reply matches the version number defined in the image gallery:
"2021.06.1782103"
If the instance id is not known, it is possible to get all instance ids of an existing scale set:
az vmss list-instances --resource-group "<resource group name>" \
--subscription "<subscription name>" \
--name <vmss name> \
--query [].instanceId
[
"1141",
"1142",
"1143"
]
To further simplify things, one could list the installed image version for each machine in an existing scale set. This allows, for example, to see if all instances are at the same version or one is left behind:
az vmss list-instances --resource-group "<resource group name>" \
--subscription "<subscription name>" \
--name <vmss name> \
--query [].storageProfile.imageReference.exactVersion
In an example with 3 instances the reply may indicate that two machines are on the later version (...03), and one machine is still on an older version of the image (...02):
[
"2021.06.1782102",
"2021.06.1782103",
"2021.06.1782103"
]
Finally, to combine this one can also query for instanceId and installed image version at the same time:
az vmss list-instances --resource-group "<resource group name>" --subscription "<subscription name>" --name <vmss name> --query "[].[instanceId,storageProfile.imageReference.exactVersion]"
[
[
"1141",
"2021.06.1782102"
],
[
"1142",
"2021.06.1782103"
],
[
"1143",
"2021.06.1782103"
]
]
You can get the exect version of image reference for one specfic instance by using the Get-AzVmssVM cmdlet with the following sytax:
(Get-AzVmssVM -ResourceGroupName $rgName -Name $ScaleSetName -InstanceId $instanceId).StorageProfile.ImageReference
I'm working on an Azure CLI script to automate the creation of a vnet in our cloud infrastructure. One of the parts in this script is linking a VNET to a Azure Private DNS. This should be easy, but apperently the difficulty is the fact that the VNET and the Private DNS are in a different resourcegroup.
This is my script;
az network private-dns link vnet create --name MyLink \
--registration-enabled true \
--resource-group my-vnet-resourcegroup\
--subscription 'My Subscription' \
--tags Domain=MyDomain \
--virtual-network my-own-vnet \
--zone-name myzone.nu
Now when exuting i'm getting the following error;
Can not perform requested operation on nested resource. Parent resource 'myzone.nu' not found.
So I updated the script to look at the resourcegroup for the private DNS;
az network private-dns link vnet create --name MyLink \
--registration-enabled true \
--resource-group my-privatedns-resourcegroup \
--subscription 'My Subscription' \
--tags Domain=MyDomain \
--virtual-network my-own-vnet \
--zone-name myzone.nu
This gives me the following error;
Deployment failed. Correlation ID: (SomeGuid). Virtual network resource not found for '/subscriptions//resourceGroups/my-privatedns-resourcegroup/providers/Microsoft.Network/virtualNetworks/my-own-vnet'
I'm quite stuck at the moment on how to fix this. Anybody else ran into this before? I'm open to suggestions!
You could pass virtual network Id to the private DNS link vNet creation if the Virtual network is in another resource group which differs from your DNS zone resource group.
VnetID=$(az network vnet show -g vnet-rg -n my-vnet --query 'id' -o tsv)
az network private-dns link vnet create -n mylink -e true -g dns-rg -z myzone.nu -v $VnetID
or, you could use Azure Powershell.
$vnet = Get-AzVirtualNetwork -name my-own-vnet -ResourceGroupName my-vnet-resourcegroup
New-AzPrivateDnsVirtualNetworkLink -ZoneName private.contoso.com `
-ResourceGroupName MyAzureResourceGroup -Name "mylink" `
-VirtualNetworkId $vnet.id -EnableRegistration
I have an image that I created in Azure that located in eastus. I want to deploy VM from that image in a different region (westeurope). I tried this CLI command but nothing is happening.
az vm create --resource-group Automationsystem --name VMEurope --location westeurope --image MyCustomImage --admin-username azureuser --size Standard_F4S --no-wait --ssh-key-value ~/mykey.pub
Is the option to deploy VM from image at another region exists?
As Lech Migdal said, you must have the image in the same region as VM.
For now, image does not support copy to other location. You need create a new image on westeurope location. Please refer to the following steps.
1.Use the image to create a VM in the current location.
2.Create a storage account in westeurope.
3.Stop VM and copy VM's managed disk to new storage account.
$sas = Grant-AzureRmDiskAccess -ResourceGroupName "[ResourceGroupName]" -DiskName "[ManagedDiskName]" -DurationInSecond 3600 -Access Read
$destContext = New-AzureStorageContext –StorageAccountName "[StorageAccountName]" -StorageAccountKey "[StorageAccountAccessKey]"
$blobcopy=Start-AzureStorageBlobCopy -AbsoluteUri $sas.AccessSAS -DestContainer "[ContainerName]" -DestContext $destContext -DestBlob "[NameOfVhdFileToBeCreated].vhd"
Note: Use image to create VM, the OS disk is managed disk.
4.Use the VHD to create a new VM, you could use the template to do this.
5.Use the VM to create a new image. Please refer to this link.
Is there a command to move Azure VM from one OMS( Log Analytics) work-space to the another OMS work-space ?
I read the documentation of AzureRmResource but not sure if this is the right option ?
According to your scenario, you need remove agent on your VM and install OMS agent with new OMS configuration. Here is the script you could use. I test in my lab, it works for me.
#!/bin/sh
# resource group name, vm nmae, OMS Id and OMS key.
rg=<resource group name>
vmname=<>
omsid="<>"
omskey=""
##Remvoe OMS agent from VM
az vm extension delete -g $rg --vm-name $vmname -n OmsAgentForLinux
# re-install and configure the OMS agent with your new OMS.
az vm extension set \
--resource-group $rg \
--vm-name $vmname \
--name OmsAgentForLinux \
--publisher Microsoft.EnterpriseCloud.Monitoring \
--version 1.0 --protected-settings '{"workspaceKey": "'"$omskey"'"}' \
--settings '{"workspaceId": "'"$omsid"'"}'
Use the command 'az vm extension set'.
Sample bash script for this.
#!/bin/sh
vmname=<Replace with your vm name>
rgname=<Replace with your Resource Group name>
omsid=<Replace with your OMS Id>
omskey=<Replace with your OMS key>
az vm extension set \
--resource-group $rgname \
--vm-name $vmname \
--name OmsAgentForLinux \
--publisher Microsoft.EnterpriseCloud.Monitoring \
--version 1.0 --protected-settings '{"workspaceKey": "'"$omskey"'"}' \
--settings '{"workspaceId": "'"$omsid"'"}'