Exercise 1: Provision an Application Endpoint and Publish its Presence

Task 1 – Create a New Trusted Application

In this task, you will create a new trusted UCMA application using Microsoft Lync Server 2010 PowerShell cmdlets.

  1. Launch the Lync Server Management Shell from Start >> Administrative Tools >> Lync Server Management Shell.
  2. Run the following command to create a new UCMA application, make sure to replace the values in < … > with the correct values for the parameters.

    PowerShell

    New-CSTrustedApplication –ApplicationId <ApplicationId> -TrustedApplicationPoolFqdn <TrustedApplicationPoolFqdn> -Port <Port>
    1. ApplicationId: “LabApp” + the value of LocalSIPPort, e.g. LabApp10600.
      1. If you are performing this exercise in your own development environment, LocalSIPPort represents an available port that Microsoft Lync Server 2010 will listen on for the new UCMA application.
    2. TrustedApplicationPoolFqdn: the fully qualified domain name of the application server in the Microsoft Lync Server 2010 topology that this application will be provisioned on, e.g. ts.fabrikam.com.
    3. Port: the port assigned for your use in the lab.

  3. Record the value displayed for the ApplicationId property.
  4. As prompted, run the Enable-CsTopology PowerShell command to commit the changes.

    PowerShell

    Enable-CsTopology

  5. Run the following command to verify that the UCMA application was created successfully, and to retrieve its details.

    The value for <Identity> is the value of TrustedApplicationPoolFqdn + “/” + the value of ApplicationName, e.g. ts.fabrikam.com/urn:application:labapp10600

    PowerShell

    Get-CSTrustedApplication –Identity <Identity>

Task 2 – Create a New Trusted Application Endpoint

In this task, you will create a UCMA application endpoint using the Microsoft Lync Server 2010 PowerShell cmdlets.

  1. Run the following command to create a new trusted UCMA application endpoint, make sure to replace the values in < … > with the correct values for the parameters.

    PowerShell

    New-CSTrustedApplicationEndpoint –ApplicationId <ApplicationId> -TrustedApplicationPoolFqdn <TrustedApplicationPoolFqdn> -SipAddress <SipAddress> -DisplayName <DisplayName>
    1. ApplicationId: The Id of the UCMA application recorded in the previous task, e.g. urn:application:labapp10600
    2. TrustedApplicationPoolFqdn: The same value as in the previous task, e.g. ts.fabrikam.com.
    3. SipAddress: The SIP URI of the Microsoft Lync contact associated with the application endpoint.
      1. In the UC 14 Metro Lab, use the following naming convention: “sip:LabContact” + the value of LocalSIPPort + “@fabrikam.com”, e.g. sip:LabContact10600@fabrikam.com
    4. DisplayName: A friendly display name for the Microsoft Lync contact associated with the application endpoint, e.g. Lab Contact 10600.

  2. Run the following command to verify that the application endpoint was created successfully and retrieve its details, where Identity is the SIP address of your lab contact, e.g. : sip:LabContact10600@fabrikam.com.

    PowerShell

    Get-CSTrustedApplicationEndpoint –Identity <Identity>

Task 3 – Open the Visual Studio Solution

In this task, you will open the project and configure it to run with your parameter values.

  1. Navigate to Start >> All Programs >> Microsoft Visual Studio 2010.
  2. Click on the Microsoft Visual Studio 2010 icon to start Visual Studio 2010.
  3. Select File >> Open Project.
  4. Navigate to the folder C:\%UC14TrainingKit%\Labs\6\Source\Before.
  5. Open the IntroductionToUCMA solution.
  6. In Solution Explorer, right-click the ProvisionedPublishAlwaysOnline project and select Set as Startup Project.
  7. In Solution Explorer, open the App.config file.
  8. Change the value of ApplicationId to the value from Task 1, e.g.: urn:application:LabApp10600.
  9. Change the value of ApplicationName to the value from Task 1, e.g.: LabApp10600.
  10. Select View >> Task List and select Comments from the menu.

Task 4 – Publish the Presence of the Application Endpoint

In this task, you will configure the UCMA application created in the previous tasks to appear as a Microsoft Lync contact whose presence always appears as Online.

  1. In the Task List, navigate to TODO: 6.1.1.
  2. Add the following code after the TODO: 6.1.1 comment. Access your application’s settings and create an instance of CollaborationPlatform for connection management, message dispatching, and other services that the Microsoft Lync Server 2010 provides to your endpoint.

    C#

    var settings = new ProvisionedApplicationPlatformSettings( _applicationName, _applicationId); _collabPlatform = new CollaborationPlatform(settings);

  3. Navigate to TODO: 6.1.2.
  4. Add the following code after the TODO: 6.1.2 comment. Create an event handler to determine the SIP URI of the contact associated with the application.

    C#

    _collabPlatform.RegisterForApplicationEndpointSettings(this.Platform_ApplicationEndpointOwnerDiscovered);

  5. Navigate to TODO: 6.1.3.
  6. Add the following code after the TODO: 6.1.3 comment. Start the CollaborationPlatform instance and specify a delegate to be called when startup completes.

    C#

    Console.WriteLine("Starting the platform."); _collabPlatform.BeginStartup(PlatformStartupCompleted, null);

  7. Navigate to TODO: 6.1.4.
  8. Add the following code after the TODO: 6.1.4 comment. Display the SIP URI of any contacts associated with the application endpoint as they are discovered.

    C#

    Console.WriteLine("Contact discovered: {0}", e.ApplicationEndpointSettings.OwnerUri);
  9. Navigate to TODO: 6.1.5.
  10. Add the following code after the TODO: 6.1.5 comment. Initialize and register the application endpoint.

    C#

    var settings = e.ApplicationEndpointSettings; settings.AutomaticPresencePublicationEnabled = true; settings.Presence.PresentityType = "automaton"; settings.Presence.Description = "AlwaysOnlineBot"; _applicationEndpoint = new ApplicationEndpoint(_collabPlatform, settings);
  11. Navigate to TODO: 6.1.6.
  12. Add the following code after the TODO: 6.1.6 comment. Establish the endpoint.

    C#

    _applicationEndpoint.EndEstablish(result); Console.WriteLine("The application endpoint owned by URI: {0} is now established and registered.", _applicationEndpoint.OwnerUri);

  13. Go to Debug >> Start Without Debugging or use the shortcut key [CTRL]+[F5] to start the application.
  14. Press the Enter key.

  15. Press Enter to shut down the console application.
  16. Open Microsoft Lync.
  17. Type the SIP URI of the application contact into the search box, the contact should appear in the search results.
  18. Verify that the presence of the contact appears as Available.
  19. Add the contact to your Microsoft Lync contact list.