[Azure Stack] Deploy a custom item in the Market Place

February 5, 2016 at 7:00 am in Azure Stack, Microsoft, TP1 by Florent

Based on the following article, I will explain to you how to import a custom item (template) in the Azure Stack Market Place.

To start, create you custom image, with the following article: http://scug.be/florent/2016/02/04/azure-stack-add-a-custom-image-to-your-library/

When it’s done, get values of the manifest of you VHD:

image

We can now start to create our template. Download the Azure Gallery Packaging Tool and a Sample Gallery Package before starting the creation. Extract it, and rename the folder SimpleVMTemplate with the name of your item that you will show on your Azure Stack Portal:

image

Now, create an ARM template or download one from this GitHub or this one. I will create a new one, based on the Windows Server 2012 R2 that is already available in Azure Stack. Replace the values of your ARM template in the imageReference part by the value that you get from the manifest file of the VHD just before:

"imageReference": {
  "publisher": "FlorentAppointaire",
  "offer": "WindowsServer",
  "sku": "2016-TP4"
},

You can test it before to be sure that he is working without problem. Save your template in your folder\DeploymentTemplates:

image

You can change icons in the Icons folder with using specific sizing, available here. You can modify the text too, in the strings/resources.json file, with the following references.

image

Now, we will modify the manifest. Open it and modify the following:

1 – The same name as your folder name
2 – The name of the publisher, without space
3 – The version of your template
4 – The name that the customer will show
5 – The publisher name that the customer will see
6 – The publisher legal name
7 – The path where your UIDefinition.json is stored
8 – The path and the name of your json template file
9 – If you have a second one, provide it
10 – The path and the name for each icons, the small, medium and large are mandatory
11 – The name of the category where this template will be displayed. You can add multiple categories

image

Save your file and open a command prompt. Navigate to the AzureGalleryPackageGenerator folder:

image

Execute the following command, by replacing by your own values, to generate the template with the extension .azpkg:

AzureGalleryPackager.exe package –m <path to manifest.json> -o <output location for the package>

In my case:

AzureGalleryPackager.exe package -m "C:\Users\flore\Downloads\Azure Stack Marketplace Item Generator and Sample\Azure Stack Marketplace Item\WindowsServer-2016-TP4\manifest.json" -o "C:\Users\flore\Downloads\Azure Stack Marketplace Item Generator and Sample\Azure Stack Marketplace Item"

image

If no error message appear, go to the output location that you provide. You will have a new file, with the following structure:

publisher.name.version.azpkg

image

Now that the item is created, it’s time to import it in Azure Stack. Copy this file to your Azure Stack ClientVM. You need an admin account to import it. Make sure that a valid ResourceGroup is available to store your item. For the name parameter, it will be the name of your package, without the extension .azpkg.  And for the path, give the path to the .azpkg file. Open a PowerShell prompt and execute the following script to import the resource in your gallery:

# Add the Microsoft Azure Stack environment
[net.mail.mailaddress]$AadFullMailAddress="azurestack@azurelabdvo.onmicrosoft.com"
$AadTenantId=(Invoke-WebRequest -Uri (‘https://login.windows.net/’+($AadFullMailAddress.Host)+’/.well-known/openid-configuration’) -UseBasicParsing|ConvertFrom-Json).token_endpoint.Split(‘/’)[3]

# Configure the environment with the Add-AzureRmEnvironment cmdlt
Add-AzureRmEnvironment -Name ‘Azure Stack’
    -ActiveDirectoryEndpoint ("https://login.windows.net/$AadTenantId/")

    -ActiveDirectoryServiceEndpointResourceId "https://api.azurestack.local/")
    -GalleryEndpoint ("https://gallery.azurestack.local/")

    -GraphEndpoint "https://graph.windows.net/"

# Authenticate a user to the environment (you will be prompted during authentication)
$privateEnv = Get-AzureRmEnvironment ‘Azure Stack’
$privateAzure = Add-AzureRmAccount -Environment $privateEnv -Verbose
Select-AzureRmProfile -Profile $privateAzure

# Select an existing subscription where the deployment will take place
$Subscription = Get-AzureRmSubscription -SubscriptionName "Default Provider Subscription"  | Select-AzureRmSubscription
$subId = Get-AzureRmSubscription -SubscriptionName "Default Provider Subscription" | Select SubscriptionId

Add-AzureRMGalleryItem -SubscriptionId $subId.SubscriptionId -ResourceGroup MarketplaceItems -Name FlorentAppointaire.WindowsServer-2016-TP4.1.0.0 -Path C:\Temp\FlorentAppointaire.WindowsServer-2016-TP4.1.0.0.azpkg  -Apiversion "2015-04-01" –Verbose

image

If the deployment has a StatusCode to OK, it’s good. Go to the user interface, and in the Market Place, go to the category that you mentionned in the Manifest. You will be able to see your new template:

imageimage

 

Following the 2 items that I created for Azure Stack:

Tell me if you need more or if you have any remarks/questions Sourire