Hands-On Microsoft SQL Server 2008 Integration Services part 61 pdf

10 238 0
Hands-On Microsoft SQL Server 2008 Integration Services part 61 pdf

Đang tải... (xem toàn văn)

Thông tin tài liệu

578 Hands-On Microsoft SQL Server 2008 Integration Services read the configuration file path from an environment variable. So when you deploy the package, the configuration file is available to the package via the environment variable. When you create an indirect configuration for an XML configuration file, instead of specifying the file path directly, you point your package to read the file path for the XML configuration file from an environment variable. The computer-specific XML configuration file defines the environment on the deployment computer. Once you have created such XML configuration files for each computer, the package deployment gets reduced to copying your package to these computers. For still more complex environments, you can update the variable values in the package during run time using configurations, and the variables in turn modify properties of the package through the use of property expressions. In this way, you can have a totally disjointed configuration for your package with different bits playing their roles independently of each other, yet in a coordinated way. The concept of indirect configurations may seem complex, but in reality is simple to adapt and use; quite interestingly, we already use this concept in real life. Think of your car as a package that has properties such as steering wheel position, pressure on the brake pedal, and so on. These properties change the behavior of the package, the car in our analogy. You, the driver, are modifying these properties that are analogous to property expressions. To modify the properties of car, you are guided by the road conditions (variable values in package analogy), such as traffic lights or traffic signs. And, above all, these road conditions are regulated and applied by a traffic regulating agency, which is the configuration file in our package. So the package configuration sets the environment (traffic lights), the environment changes the variable values (traffic light turning green), and using those modified values, property expressions modify the behavior of the package (applying the brake to stop the car). Hands-On: Using Indirect Configurations You will be creating an indirect package configuration for downloading the zipped files package that you created in Chapter 5. Method For indirect configurations, you create a configuration file on the computer to which you want to deploy the package. This configuration defines the environment for the computer, which is used by the package to modify its properties. The following steps will be used for this exercise: Create a computer-specific package configuration. c Create an environment variable. c Chapter 13: Deploying Integration Services Packages 579 Use property expressions to update the ConnectionString property. c Create an indirect package configuration. c Deploy and execute the package. c A couple of things to note here: If you want to use the Downloading zipped files package that has been provided with this book, you will receive an error when opening the package. When you click OK for the error dialog, the package will load properly sans the connection string in the FTP task. This is because, by default, the sensitive information (passwords, connection strings, and so on) in the packages get encrypted using the user key (my user key in this case), and when someone else tries to open the package, an error will occur and sensitive information will be removed from the package. However, if you open the Downloading zipped files package that you developed yourself in Chapter 5, you will not get such an error. This package requires a connection to an FTP server. If you skipped building this package in Chapter 5, I would recommend that you find an FTP server (many FTP sites allow you to download files that you can use to build this package—e.g., FTP sites for antivirus updates) and build the package to work through this Hands-On exercise. The provided package may not be of much help, as it points to my home computer, which is obviously not accessible to you. Exercise (Create a Computer-Specific Package Configuration) To deploy the package to multiple computers, you need to develop a configuration for each computer. You may do this at the development computer or at the deployment computer, depending upon the available resources. Once the configuration has been created, you then deploy the configuration file on the deployment computer. In this exercise, you will be using a development computer to create this configuration file. 1. Start BIDS and create a new Integration Services project with the following details: Name Downloading zipped files with Indirect Configurations Location C:\SSIS\Projects 2. After a blank project is created, add the existing package Downloading zipped files.dtsx from C:\SSIS\Projects\Control Flow Tasks\ folder. Also, delete the Package.dtsx blank package. Open the Downloading zipped files.dtsx package by double-clicking it. 3. Verify that the variable fpath exists in the package with the details shown next. Otherwise, add this variable by right-clicking anywhere on the blank surface of 580 Hands-On Microsoft SQL Server 2008 Integration Services the Designer and choose Variables from the context menu. Add a variable with the following details: Name fpath Data Type String 4. Now right-click anywhere on the blank surface of the Designer and choose Package Configurations from the context menu. Select the Enable Package Configurations check box. 5. Click Add to start the Package Configuration Wizard. Click Next on the first screen, and on the Select Configuration Type screen, choose the Configuration Type as XML Configuration file. 6. Select the Specify Configuration Settings Directly radio button. This will highlight the Configuration File Name field. Type C:\SSIS\Projects\Downloading zipped files with Indirect Configurations\Configurations for DZF.dtsConfig as the filename (see Figure 13-6). Click Next to move to the Select Properties To Export screen. This file path is not of much relevance, as we will finally move this file to the computers where the package will be deployed. Figure 13-6 Creating configurations for the deployment computer Chapter 13: Deploying Integration Services Packages 581 7. In the Objects pane, under the Downloading zipped files, expand the Variables\ fpath\Properties. Check the Value property, as shown in Figure 13-7. Click Next to go to the next screen. 8. Type Downloaded files path in the Configuration Name field on the Completing The Wizard screen. Note that the Preview section shows the Type as Configuration File and tells you that a new configuration file will be created. Also note that the property \Package.Variables[User::fpath].Properties[Value] has been structured in a particular way. The basic rule here is that executables (containers or tasks) will start with a backslash (\); variables, properties, and connection managers will start with a dot (.); and an item in the collection will be enclosed within square brackets ([ ]). Starting with \Package, the variables collection has been started with a dot, which is then followed by the [User::fpath] variable enclosed in square brackets because it is one in the collection of variables. This is then followed by Properties, starting with a dot and the [Value] item in the properties collection enclosed within square brackets. Click Finish to complete the wizard and return to the Package Configurations Organizer dialog box. You will see that the newly created configuration has been added to the Configurations section. Click Close to return to the Designer surface. Figure 13-7 Selecting properties to export 582 Hands-On Microsoft SQL Server 2008 Integration Services 9. Open the newly created configuration file Configurations for DZF.dtsConfig from the Designer menu: choose File | Open File and provide the path specified in Step 6. This will open a new tab on the Designer surface showing the XML configuration file. Locate the <ConfiguredValue> element and specify C:\SSISDeploy after the <ConfiguredValue> and before </ConfiguredValue> element. Save and close this file. 10. Choose File | Save All; then close the project and exit BIDS. Exercise (Create an Environment Variable) Let’s now move the configuration file to the deployment computer and set up an environment variable on the deployment computer to point to the configuration file. In real life, you will be setting up an environment variable on a development computer, a UAT server, a staging server, a production server, and others, but the path value defined for the environment variable on the deployment computer will differ from computer to computer, depending on your requirements. 11. Create a folder on the deployment computer named C:\SSISDeploy, and move the newly created configuration file Configurations for DZF.dtsConfig from your development computer to this folder on the deployment computer. 12. Create a new environment variable on the deployment computer. Usually, the Environment Variables dialog box is found in the advanced system settings of My Computer Properties. 13. In the Environment Variables window, click the New button in the System Variables section and click the OK button in the pop-up window after typing in the following details: Variable Name DZFConfig Variable Value C:\SSISDeploy\Configurations for DZF.dtsConfig 14. You can scroll through the list of system variables to see this variable added to the list (Figure 13-8). 15. Repeat Steps 11 through 13 on the development computer so that you have access to the run-time environment on the development computer as well as for designing and testing purposes. Exercise (Use Property Expressions to Update Exported Properties) Now you’ll use property expressions to update the ConnectionString property of the Downloads Connection Manager so that the downloaded zipped files can be saved to a folder specified by the fpath variable. BIDS requires a restart to load new environment Chapter 13: Deploying Integration Services Packages 583 settings. So if BIDS is already open, exit from it and then start it again to load the newly created the environment variable. 16. Open the Downloading zipped files with Indirect Configurations project using BIDS on the development computer. 17. Right-click the Downloads Connection Manager in the Connection Managers area and choose Properties from the context menu. In the Properties window, click in the Expressions field and then click the ellipsis button to open the Property Expressions Editor. Click in the field under the Property column and select ConnectionString from the drop-down list. Click the ellipsis button next to the Expressions field to build an expression. In the Expression Builder dialog box, expand Variables and then drag the User::fpath variable to drop in the Expression box. Click OK twice to return to the Properties window, shown in Figure 13-9. Exercise (Create Indirect Package Configuration) Till now you have created a configuration file to update the value of the fpath variable and the property expression to use fpath to update the ConnectionString property of the Downloads Connection Manager. Also, you have moved the configuration file to Figure 13-8 Creating an environment variable for indirect configuration 584 Hands-On Microsoft SQL Server 2008 Integration Services a different computer, which is now not accessible to your package. You have created an environment variable that points to the already-created configuration file. In this part you will point your package to read the configuration file from the location specified by the environment variable you created earlier. To do this, you will use an indirect configuration. 18. In BIDS, right-click anywhere on the blank surface of the Designer and choose Package Configurations from the context menu. In the Configurations list box, you will see the previously configured Downloaded files path configuration listed there. Click Remove to delete this configuration. 19. Click Add to create a new configuration. Click Next on the Welcome screen of the Package Configuration Wizard. 20. In the Select Configuration Type screen, choose XML Configuration File in the Configuration Type field. Next, click the radio button for “Configuration location is stored in an environment variable.” So instead of specifying an XML Figure 13-9 Creating a property expression for ConnectionString property Chapter 13: Deploying Integration Services Packages 585 filename, you will be using an environment variable here. Select DZFConfig from the drop-down list in the Environment Variable field (see Figure 13-10). You are telling your package that you are using an XML configuration file to define your configurations whose location information is located in the environment variable DZFConfig. Click Next. 21. Type DZFConfig file connection in the Configuration Name field on the Completing The Wizard screen. Note that the Preview section shows the Type as Indirect Configuration File and the Environment Variable Name as DZFConfig. Click Finish to complete the wizard and return to the Package Configurations Organizer. The newly created configuration gets added to the Configurations list. 22. Click Close to return to the Designer surface. With the creation of this configuration, you have completed all the configuration steps required for indirect package configurations. Pointing the package to read information from an environment variable doesn’t result in creation of any external file; rather, this information is embedded in the package itself. This enables you to copy your package to any computer and the package will look to the environment on the computer to get the location information for the configuration file from environment variable. Save all the files and exit from BIDS. Figure 13-10 Using an environment variable to create indirect configurations 586 Hands-On Microsoft SQL Server 2008 Integration Services Exercise (Deploy and Execute the Package) In the final exercise, you will deploy your package to the computer where you want to run it, and execute it to see how the package behaves with the indirect package configurations. 23. Copy the Downloading zipped files.dtsx file from the C:\SSIS\Projects\ Downloading zipped files with Indirect Configurations folder on the development computer to the root folder of the C: drive on the deployment computer. (Actually, you can choose any folder on the deployment computer to host your package file.) 24. Open the command prompt window and type the following command: dtexec /file "Downloading zipped files.dtsx" You will see the package executed successfully with a DTSER_SUCCESS message, as shown in Figure 13-11. 25. Go to C:\SSISDeploy folder and notice that the two zipped files have been downloaded in that folder. Review You have learned how to use indirect package configurations to simplify the deployment or redeployment process to a mere copy operation in situations for which you must deploy to many machines or you must deal with complex requirements of applying configurations. During package loading time, as the configurations have been enabled, the package knows that it has to load configurations from an XML configuration file, which can be accessed from the path specified by the environment variable. So, the package goes to the environment variable DZFConfig, which directs it to the C:\SSISDeploy\Configurations Figure 13-11 Using the dtexec utility to execute the package on the deployment computer Chapter 13: Deploying Integration Services Packages 587 for DZF.dtsConfig file. On reading this file, the package sets the fpath variable value to C:\SSISDeploy. And during the package execution time, the property expressions read the value of the User::fpath variable and update the ConnectionString property of the Downloads Connection Manager and hence copy the zipped files to C:\SSISDeploy folder. As a last point on running the package on the deployment computers, you can actually run SSIS packages on a computer that doesn’t necessarily have SQL Server installed. All you need to run SSIS packages on a computer is the .NET framework and SSIS run-time environment installed. Deployment Utility After you have created package configurations for the package, you are ready to deploy your package to the various computers that are going to do the work. You might not understand the difference between copying a package and deploying a package. Truth is, there’s no difference if your package is simple enough that it has no configuration file or miscellaneous files that have to be taken care of. Deploying a package using the tools provided with SQL Server takes into consideration the package configuration file and any other miscellaneous files when pushing the package to the deployment computer. The following methods can be used to deploy a package to a computer: Using the import and export facility of Integration Services within SQL Server c Management Studio Saving a package to the file system or to the SQL Server store c Copying or moving packages using the dtutil utility c Using a package deployment utility c Using a custom deployment tool or home-grown scripts to deploy packages c You have used the first three methods in Chapter 6 when you were learning about administration of Integration Services. This approach is suitable for simple single- package projects or when you develop a package on the machine where you want to use it. This approach is not much help when you are dealing with some or all of the following situations: e project contains several small packages as modules of a parent package. c You need to deploy Integration Services projects to several computers. c You will use package configurations to set the properties. c You will store miscellaneous files within the package. c . 578 Hands-On Microsoft SQL Server 2008 Integration Services read the configuration file path from an environment variable add this variable by right-clicking anywhere on the blank surface of 580 Hands-On Microsoft SQL Server 2008 Integration Services the Designer and choose Variables from the context menu. Add a. to the Designer surface. Figure 13-7 Selecting properties to export 582 Hands-On Microsoft SQL Server 2008 Integration Services 9. Open the newly created configuration file Configurations for

Ngày đăng: 04/07/2014, 15:21

Tài liệu cùng người dùng

Tài liệu liên quan