This topic is part of the System Center 2012 R2 Virtual Machine Role Authoring Guide.

The Microsoft System Center team has validated this content as of Revision #2.  We will continue to review any changes and periodically provide validations on later revisions as they are made.  Please feel free to make any corrections or additions to this content that you think would assist other users.



Introduction

Once the Resource Definition File, View Definition File, and Resource Definition File have been created, then you can create and install the packages so that tenants can provision new Virtual Machine Roles. The following sections detail the steps required to perform this installation.

Create Packages

There is currently no packaging tool for the Resource Definition or Resource Extension. Both packages are simply .zip files with a modified extension. You can use the following procedure to create and populate these files. The specific information for each package is included in the below sections.

  1. Create a new Compressed (zipped) Folder in Windows.
  2. Add the folders and files for the package you are creating.
  3. Rename the .zip file to the extension for the package that you are creating.

Resource Definition Package

The Resource Definition package includes the contents in the following table. It has an extension of .resdefpkg.

Contents

Description

Resource Definition File

JSON file that contains instructions on how to configure the virtual machine. Must have an extension of .resdef.

View Definition File

JSON file that includes instructions on collecting parameters from the user. Must have an extension of .viewdef.

[ContentTypes].xml

File required by the OPC standard that contains a list of the MIME types and extensions for other files in the package.

Icon File

A PNG file with the icon to display in the Gallery for the Virtual Machine Role.

Localization Files

Localization files for each language that will be included with the Virtual Machine Role. Each localization file will be located in a folder named with the language code.

The following diagram illustrates the contents of a sample Resource Definition package. In this case, only US English is included for localization.

The Resource Extension package includes the following contents. It has an extension of .resextpkg.

Contents

Description

Resource Extension File

JSON file that contains instructions on how to configure the application. Must have an extension of .resext.

[ContentTypes].xml

File required by the OPC standard that contains a list of the MIME types and extensions for other files in the package.

Application Payload

Any files required for installation of the application. The setup instructions included in the RESEXT file will reference these files.

The following diagram illustrates the contents of a sample Resource Extension package. In this case, the only files required for installation of the application is a command script.

Content Types File

The OPC standard requires each package to include a file named [Content_Types].xml. This file contains a listing of the MIME types and extensions for each file contained in the package. If this file is not included in Resource Definition and Resource Extension packages, they will fail to install. Also, if a file is included in the package with an extension that is not included in the Content Types file, the package will fail to install.

Note that the ContentType setting for each extension in the Content_Types file for Virtual Machine Role packages is set to application/octet-stream rather than a specific setting for each type of file. While more specific settings for each file may work, this is not necessary and has not been tested.

An example of the contents of [Content_Types].xml for the Resource Definition package is shown below. This file will be sufficient for most Virtual Machine Roles.

<?xml version="1.0" encoding="utf-8"?>
    <Default Extension="viewdef" ContentType="application/octet-stream"/>
    <Default Extension="resdef" ContentType="application/octet-stream"/>
    <Default Extension="png" ContentType="application/octet-stream"/>
    <Default Extension="xml" ContentType=" application/octet-stream "/>
    <Default Extension="txt" ContentType=" application/octet-stream "/>
    <Default Extension="ps1" ContentType="application/octet-stream"/>
    <Default Extension="resdefpkg" ContentType="application/octet-stream"/>
    <Default Extension="resources" ContentType="application/octet-stream"/>
    <Default Extension="resext" ContentType="application/octet-stream"/>
    <Default Extension="resextpkg" ContentType="application/octet-stream"/>
    <Default Extension="cmd" ContentType="application/octet-stream"/>
</Types>

 

An example of the contents of [Content_Types].xml for the Resource Extension package is shown below. If your application payload includes file with additional extensions, then these need to be added to the file.

<?xml version="1.0" encoding="utf-8"?>
    <Default Extension="resext" ContentType="application/octet-stream"/>
    <Default Extension="zip" ContentType="application/octet-stream"/>
    <Default Extension="cmd" ContentType="application/octet-stream"/>
    <Default Extension="msi" ContentType="application/octet-stream"/>
</Types>

 

Create and Configure the VHD

The Resource Extension relies on a VHD prepared with an Operating System that matches the configuration required for the application being provisioned. If you obtained the Resource Extension from another party, then they should specify these requirements in their documentation.

The Resource Extension specifies its requirements in the Resource Requirements section of the Resource Extension File. For a VHD to be used with the Resource Extension, it must have tags that match each of these values.

You add tags to a VHD by using the Set-SCVirtualHardDisk cmdlet with the –Tag parameter. This cmdlet has the following syntax:

 

Set-SCVirtualHardDisk –VirtualHardDisk <Virtual Hard Disk> -Tag <Tags to add>

 

Example

The following Windows PowerShell commands show an example of setting the tags for a sample VHD. In this case, two tags are required for “WindowsServer2012” and “Datacenter”.

 

$vhd = Get-SCVirtualHardDisk | Where-Object {$_.Name –eq 'WS2012DC.vhd'}
Set-SCVirtualHardDisk –VirtualHardDisk $vhd -Tag 'WindowsServer2012','DataCenter'

 

Install Resource Extension Package

To install the Resource Extension package into VMM, use the Import-CloudResourceExtension cmdlet. This cmdlet has the following syntax.

 

Import-CloudResourceExtension –ResourceExtensionPath <path to RESEXT> -Description <Description for RESEXT> -SharePath <path to VMM library>

 

Example

The following Windows PowerShell commands show an example of installing the sample Resource Extension Package.

 

$libraryShare = Get-SCLibraryShare | Where-Object {$_.Name –eq 'MSSCVMMLibrary'}
$resPkgPath = "C:\Packages\IIS-WS2012.resextpkg"
Import-CloudResourceExtension -ResourceExtensionPath $resPkgPath -Description "IIS Resext" -SharePath $libraryShare

 

Install Resource Definition Package

The Resource Definition Package is installed in SPF using the Service Management Portal. You can use the following procedure to install and publish the package.

  1. On the VM Clouds workspace, select the Gallery tab.
  2. Select Install at the bottom of the window.
  3. Browse for the location of the Resource Definition Package.
  4. When the Virtual Machine Role has been added to the gallery, select it.
  5. Click Publish at the bottom of the window.

 

See Also

Resource Definition Package
Resource Extension Package
Parameters
VHD Tags
Virtual Machine Role Resource JSON Reference