Howto use RHEL BYOS azure image – RedHat

Here’s a quick post on how to subscribe and use the preview enabling you to test/use the RHEL image in BYOS (Bring Your Own Subscription) model.

 

If you are reading this you probably already have found the RHEL image named rhel-byos in azure, but you were unable to use them because it was private.

I was going to share the link here, but as far as I’ve been told, I can’t. So please contact your Redhat rep or Microsoft rep if you want to join the preview. You probably can open a ticket on azure portal.

 

Important thing to know once you’re in the preview program:

You have to accept the Terms, don’t forget the:

| Set-AzureRmMarketplaceTerms -Accept

Even if the publisher name is RedHat when you lookup the image, when you want to use it, you have to use “redhat” all lowercase.

 

Here’s the powershell script I used to test the deployment once I was in the preview.

# Variables for common values
$resourceGroup = "testbyos"
$location = "canadaeast"
$vmName = "test02"

# Define user name and blank password
$securePassword = ConvertTo-SecureString 'XXXXXX!' -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential ("azureuser", $securePassword)

Get-AzureRmMarketplaceTerms -Publisher redhat -Product rhel-byos -Name rhel-lvm75 | Set-AzureRmMarketplaceTerms -Accept

# Create a resource group
New-AzureRmResourceGroup -Name $resourceGroup -Location $location

# Create a subnet configuration
$subnetConfig = New-AzureRmVirtualNetworkSubnetConfig -Name mySubnet -AddressPrefix 192.168.1.0/24

# Create a virtual network
$vnet = New-AzureRmVirtualNetwork -ResourceGroupName $resourceGroup -Location $location `
-Name MYvNET -AddressPrefix 192.168.0.0/16 -Subnet $subnetConfig

# Create a public IP address and specify a DNS name
$pip = New-AzureRmPublicIpAddress -ResourceGroupName $resourceGroup -Location $location `
-Name "mypublicdns$(Get-Random)" -AllocationMethod Static -IdleTimeoutInMinutes 4

# Create an inbound network security group rule for port 22
$nsgRuleSSH = New-AzureRmNetworkSecurityRuleConfig -Name myNetworkSecurityGroupRuleSSH -Protocol Tcp `
-Direction Inbound -Priority 1000 -SourceAddressPrefix * -SourcePortRange * -DestinationAddressPrefix * `
-DestinationPortRange 22 -Access Allow

# Create a network security group
$nsg = New-AzureRmNetworkSecurityGroup -ResourceGroupName $resourceGroup -Location $location `
-Name myNetworkSecurityGroup -SecurityRules $nsgRuleSSH

# Create a virtual network card and associate with public IP address and NSG
$nic = New-AzureRmNetworkInterface -Name myNic -ResourceGroupName $resourceGroup -Location $location `
-SubnetId $vnet.Subnets[0].Id -PublicIpAddressId $pip.Id -NetworkSecurityGroupId $nsg.Id

# Create a virtual machine configuration
$vmConfig = New-AzureRmVMConfig -VMName $vmName -VMSize Standard_D3_v2 |
Set-AzureRmVMOperatingSystem -Linux -ComputerName $vmName -Credential $cred |
Set-AzureRmVMSourceImage -PublisherName redhat -Offer rhel-byos -Skus rhel-lvm75 -Version latest |
Add-AzureRmVMNetworkInterface -Id $nic.Id

Set-AzureRmVMPlan -VM $vmConfig -Publisher redhat -Product rhel-byos -Name rhel-lvm75

# Configure SSH Keys
#$sshPublicKey = Get-Content "$env:USERPROFILE\.ssh\id_rsa.pub"
#Add-AzureRmVMSshPublicKey -VM $vmconfig -KeyData $sshPublicKey -Path "/home/azureuser/.ssh/authorized_keys"

# Create a virtual machine
New-AzureRmVM -ResourceGroupName $resourceGroup -Location $location -VM $vmConfig

Author: Arsenick

Hi all! I'm a 27 years old guy from Quebec city, Canada. I've been playing with Linux since 1998 and start to earn my life using Linux and FOSS around 2005. Since then I've earned few certification and courses including CLP10 (Certified Linux Professional from Novell), RHCE (RedHat Certified Engineer) and JBOSS Administration course. I'm a Linux sys admin and I'm working here in Quebec city for a small company who are RedHat Advanced partner since few years. So I'm trying to always keep me updated on new technology and new RedHat product. The best way I've found to do it is to use and contribute to the Fedora Community. So I've joined the community in mid 2009 as a Fedora Ambassadors, I still learning how everything work in a opensource community, but I really liked what I saw at the 2009 FUDCON in Toronto.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.