Authoring Management Packs using the System Center 2012 Visual Studio Authoring Extensions

For those of you who often work with management pack XML code, the Visual Studio Authoring Extensions (VSAE) might be a useful solution. The following features are a selection of what VSAE adds to Visual Studio:

  • Management Pack project templates for SCSM and SCOM
  • Support for XML fragments containing different management pack elements
  • True XSD validation with IntelliSense
  • Automatic sealing and MP bundling as part of the build process
  • Automatic deployment of MPs to your management group

The Visual Studio Authoring Extensions for System Center 2012 can be downloaded from the following URL: http://www.microsoft.com/en-us/download/details.aspx?id=30169. As a prerequisite, you need Visual Studio 2010 Professional or higher installed on your computer.

Once VSAE has been installed, you will notice that new project templates are available in Visual Studio under the “Management Pack” node. We will start with creating a new solution named “Custom.SCSM.CI.Classes”.

image

I will now add a management pack fragment which defines a new class named “Custom.CI.PeripheralDevice”. Right-click the project in Solution Explorer, and select “Add” – “New Item”. We are going to use the “Class” fragment template for this task.

Visual Studio will now load a template which already contains a sample class definition and some comments. You will now need to adjust the code to define your class. Notice how Visual Studio automatically validates the schema and also supports IntelliSense.

image

image

Please make sure to also include the DisplayStrings for your class and the properties. My code looks something like this:

<ManagementPackFragment SchemaVersion="SM2.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
<TypeDefinitions>
<EntityTypes>
<ClassTypes>
<ClassType ID="Custom.CI.PeripheralDevice" Extension="false" Singleton="false" Hosted="false" Base="System!System.Device" Abstract="false" Accessibility="Public">
<Property ID="PeripheralDeviceID" Scale="0" Required="true" MinLength="0" MaxLength="256" CaseSensitive="false" Key="true" AutoIncrement="false" Type="int"/>
<Property ID="Type" Scale="0" Required="false" MinLength="0" MaxLength="256" CaseSensitive="false" Key="false" AutoIncrement="false" Type="enum" EnumType="Custom.CI.Enum.PeripheralDevice.Type"/>
<Property ID="DeviceName" Scale="0" Required="false" MinLength="0" MaxLength="20" CaseSensitive="false" Key="false" AutoIncrement="false" Type="string"/>
<Property ID="Description" Scale="0" Required="false" MinLength="0" MaxLength="100" CaseSensitive="false" Key="false" AutoIncrement="false" Type="string"/>
<Property ID="SerialNumber" Scale="0" Required="false" MinLength="0" MaxLength="50" CaseSensitive="false" Key="false" AutoIncrement="false" Type="string"/>
<Property ID="AssetNumber" Scale="0" Required="false" MinLength="0" MaxLength="20" CaseSensitive="false" Key="false" AutoIncrement="false" Type="string"/>
</ClassType>
</ClassTypes>
</EntityTypes>
</TypeDefinitions>
<LanguagePacks>
<LanguagePack ID="ENU" IsDefault="true">
<DisplayStrings>
<DisplayString ElementID="Custom.CI.PeripheralDevice">
<Name>Peripheral Device</Name>
</DisplayString>
<DisplayString ElementID="Custom.CI.PeripheralDevice" SubElementID="PeripheralDeviceID">
<Name>ID</Name>
</DisplayString>
<DisplayString ElementID="Custom.CI.PeripheralDevice" SubElementID="Type">
<Name>Type</Name>
</DisplayString>
<DisplayString ElementID="Custom.CI.PeripheralDevice" SubElementID="DeviceName">
<Name>Device Name</Name>
</DisplayString>
<DisplayString ElementID="Custom.CI.PeripheralDevice" SubElementID="Description">
<Name>Description</Name>
</DisplayString>
<DisplayString ElementID="Custom.CI.PeripheralDevice" SubElementID="SerialNumber">
<Name>Serial Number</Name>
</DisplayString>
<DisplayString ElementID="Custom.CI.PeripheralDevice" SubElementID="AssetNumber">
<Name>Asset Number</Name>
</DisplayString>
</DisplayStrings>
</LanguagePack>
</LanguagePacks>
</ManagementPackFragment>

Next, I am going to add another management pack fragment which defines an enumeration type for the “Type” property of my class. Right-click the project in Solution Explorer, and select “Add” – “New Item”. We are going to use the “Class” fragment template for this fragment as well.

Add the code to hold your enumeration type definition and the required DisplayStrings, such as the following:

<ManagementPackFragment SchemaVersion="SM2.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
<TypeDefinitions>
<EntityTypes>
<EnumerationTypes>
<EnumerationValue Accessibility="Public" ID="Custom.CI.Enum.PeripheralDevice.Type" />
<EnumerationValue Accessibility="Public" ID="Custom.CI.Enum.PeripheralDevice.Type.Monitor" Ordinal="1" Parent="Custom.CI.Enum.PeripheralDevice.Type" />
<EnumerationValue Accessibility="Public" ID="Custom.CI.Enum.PeripheralDevice.Type.Scanner" Ordinal="2" Parent="Custom.CI.Enum.PeripheralDevice.Type" />
</EnumerationTypes>
</EntityTypes>
</TypeDefinitions>
<LanguagePacks>
<LanguagePack ID="ENU" IsDefault="true">
<DisplayStrings>
<DisplayString ElementID="Custom.CI.Enum.PeripheralDevice.Type">
<Name>Peripheral Device Type</Name>
</DisplayString>
<DisplayString ElementID="Custom.CI.Enum.PeripheralDevice.Type.Monitor">
<Name>Monitor</Name>
</DisplayString>
<DisplayString ElementID="Custom.CI.Enum.PeripheralDevice.Type.Scanner">
<Name>Scanner</Name>
</DisplayString>
</DisplayStrings>
</LanguagePack>
</LanguagePacks>
</ManagementPackFragment>

Before we build the solution, let’s take a look at the project properties and build options we have. Right-click the project in Solution Explorer, and click “Properties”.

Let’s first define the build options. I want my management pack to be sealed automatically as part of the build process, so let’s specify the corresponding options.

image

Also, I want Visual Studio to automatically deploy my management pack to Service Manager, so let’s add the Management Group Connection to the project and configure deployment options.

image

image

Now, let’s build our solution by pressing F6. When the management pack was built successfully, you can find your management pack in the “\bin\Debug” folder of your project. The management pack will be saved in XML, as a sealed management pack (.MP), and as a management pack bundle (.MPB).

Notice that VSAE also verifies your management pack as part of the build process. If an error is detected, the build process will be aborted, and you no longer have to import your management pack into Service Manager first before you find out that you made a typo.

image

Now, of course we do not want to manually import the management pack into Service Manager. We have configured deployment options, remember?

So let’s go back to Visual Studio and press F5.

image

Now, let us check the result in the Service Manager Console.

image

This is proof that the deployment process finished successfully… cool!

Smile

I hope that this example gave you an overview of how VSAE can be used to support your MP authoring process. Download and install the add-on today to discover its features and benefits!

About these ads

9 Responses to Authoring Management Packs using the System Center 2012 Visual Studio Authoring Extensions

  1. Sam Erskine says:

    I like this. great blog post

  2. Good work! Keep on Blogging!

  3. Julian says:

    Hello Dieter,
    really good post, it was a nice help for the first steps with Visual Studio Authoring Extensions.
    But I have one question:
    Where can I find documantion about attributes like “Scale”, “AutoIncrement” and so on.
    I only found this:
    http://msdn.microsoft.com/en-us/library/ee533714.aspx

    P.S: I’m new to SCOM and have to develop a management pack for a custom application

    Thanks and regards
    Julian

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: