Note: Cross posted from Nothing geeky....
Permalink

    Lab management 2010 helps in automating the daily build scenario end to end, using the build-deploy-test workflow.

    The deployment scripts being run as part of the workflow can be anything from a batch file to an MSI or a power shell script. Few in-built macros are available to facilitate authoring of deployment scripts. Let us go through the macros in this post.

    Build location macro:

  • Denoted by $(BuildLocation).
  • Refers to the location from where the binaries will be picked up for deployment. It depends on the option that is chosen in the "Build" page in the "Lab Workflow parameters" wizard. If "TeamBuild" option is chosen, then the drop location of the concerned build will be referred to. If a build location is specified explicitly, then that location will be used.

clip_image001[10]

Internal Computer Name macro :

  • Denoted by $(InternalComputerName_<VMName>).
  • Refers to the bare host name of the specific virtual machine inside the environment.

Example : Consider an environment by name "NightlyBuild" with virtual machines by name "Webserver" and "DBServer".To refer to the computer name of the "WebServer" virtual machine, specify $(InternalComputerName_WebServer).

Computer Name macro :

  • Denoted by $(ComputerName_<VMName>).
  • Similar to $(InternalComputerName _VMName) macro. But this will expand to FQDN name instead of bare host name.

    Why two macros for referring to computer name ?

    Consider a virtual machine with computer name "mywebserver". The FQDN name of this machine will be something like "mywebserver.mydomain.com", where "mydomain.com" is the domain to which the machine is connected to. This is the regular case.

    But in the case of a network isolated lab environments, it is a bit different. Lab management will assign a unique FQDN name for each virtual machine inside a network isolated lab environment. So if we have a virtual machine with computer name "mywebserver" which is part of a network isolated environment, then its bare host name is going to be "mywebserver" and FQDN will be "VSLM_<GUID>.mydomain.com".

    The bare host name will be used for internal communication( to talk to machines within the isolated environment ) and FQDN name will be used for external communication. In other words, imagine the network isolated environment to be "fenced" environment. For communication within the fence, use $(InternalComputerName_VMName) macro and for communication outside the fence use $(ComputerName_VMName) macro.

    For regular environments(non network isolated) environments both the macros can be used inter changeably, unless you have a specific need to use only FQDN or only bare host name.

    A small Tip:

    In the web server machine, if IIS runs as network service, then to grant permissions for IIS on SQL DB, the machine$ account need to be added. In sense, if the web server machine name is "webserver-IIS7", then to grant IIS permissions on SQL DB, the "domain\webserver-IIS7$" account need to be added. Here FQDN name won’t work. Only bare host name will work. For such things $(InternalComputerName_VMName) macro can be used.

    Sample Deployment script with Macros :

    Below is a sample deployment script for setting up a web app. It invokes a batch file by name "CopyScripts.bat" which will be present in a sub folder in the drop location. The batch file takes the drop location as an argument.It copies all the binaries to a local folder in the WebSever virtual machine.

After copying the binaries and scripts, appropriate scripts are invoked to setup the data tier and web tier. For setting up data tier, the machine of web server machine is  passed as parameter for provisioning SQL access. Similarly for setting up web tier, the computer name of DBServer machine is passed for configuring data connection strings in web.config file.

image