SSIS 2008R2 Dynamically Change Web Reference URL for Different Environments - web-services

I'm running MSSQL 2008 R2.
I want to be able to dynamically change the Web Reference URL in a Script Task when the package is deployed in different environments without having to change it manually and build it again each time.
I've got the Script Task to work with the Test Web Service,
I've added the Wed Reference in the Script Task and set the URL behaviour to "Dynamic".
I've got a Package Variable called "WebServiceURL".
so what do I need to do now in the Script Task for it to use the "WebServiceURL" package variable when calling the Web Service.
I know very little C# .Net.
Thanks in advance.

Take a look at this question.
How can I dynamically switch web service addresses in .NET without a recompile?
You probably want to set the .URL property of the class that calls the web service to the URL from your package variable, since the .config file for SSIS packages varies depending on where it is called from.
You can read a package variable by selecting the specific variable in the "Custom Properties / Read Only Variables" property in the window that you get when you first double click on a script task. Once its selected, you can use it in your code (the Variables class is automatically generated with each variable as a property).

Related

AWS AppStream How do I test Session Context with SessionContextRetriever.exe

I'm using AWS AppStream to stream a legacy .NET client. The app requires a parameter to start up correctly, which it gets via SessionContext passed into the create_streaming_url API call. I'd like to test this interaction locally without having to redeploy my app for every debug iteration as that takes well over half an hour. According to the AWS AppStream Docs session-context is stored in an environment variable that is only accessible via the AWS provided SessionContextRetriever.exe .NET application. The docs list the environment var as AppStream_Session_Context. I've tried setting this env var and running SessionContextRetriever.exe with no success. There is no documentation that I can find for SessionContextRetriever.exe but there's obviously something I'm missing here. Anybody have any experience with AppStream and session context?
The executable they provide doesn't come with a license, so I have to presume that it's copyrighted and licensed restrictively etc. So de-compiling it would be not be a good idea. But if somebody were to do such a thing, I would expect them to find something like
Console.Write(Environment.GetEnvironmentVariable("APPSTREAM_SESSION_CONTEXT", EnvironmentVariableTarget.Machine));
So I suggest that you try setting the environment variable at the system level for testing. That is, setting it in a script won't be visible to this executable because it's not looking at your current terminal session.
Setting the environment variable at the system level (using the Windows "Edit system environment variables) I see the output from this executable.
Run PS as Administrator:
PS C:\Users\Public\Apps> setx -m AppStream_Session_Context "Value"
PS C:\Users\Public\Apps> .\SessionContextRetriever.exe
Value

Determine whether I'm running on Cloudhub or Locally

I am building a Mulesoft/Anypoint app for deployment on Cloudhub, and for diagnostic purposes want to be able to determine (from within the app) whether it is running on Cloudhub or in Anypoint Studio on my local development machine:
On Cloudhub, I want to use the Cloudhub connector to create notifications for exceptional situations - but using that connector locally causes an exception.
On my local machine, I want to use very verbose logs with full dumping of the payload (#[message.payloadAs(java.lang.String)]) but want to use much more concise logging when on Cloudhub.
What's the best way to distinguish the current runtime? I can't figure out any automatic system properties that expose this information.
(I realize the I could set my own property called something like system.env=LOCAL and override it with system.env=CLOUDHUB for deployment, but I'm curious if the platform already provides this information in some way.)
As far as I can tell the best approach is to use properties. The specific name and values you use doesn't matter as long as you're consistent. Here's an example:
In your local dev environment, set the following property in mule-app.properties:
system.environment=DEV
When you deploy to Cloudhub, use the deployment tool to change that property to:
system.environment=CLOUDHUB
Then in your message processors, you can reference this property:
<logger
message="#['${system.environment}' == 'DEV' ? 'verbose log message' : 'concise log message']"
level="ERROR"
doc:name="Exception Logger"
/>

Deploying Web job with appropriate environments variable

We are trying to deploy a web job via octopus. We have different eventhub keys saved in the variables and we expect the webjob to pick up the right key depending on the environment that it is being deployed to. Has one one done this before? Any advice on settings up configurations in octopus?
<========== UPDATE ===========>
We were being careless and didn't quite set our octopus process to transform the Configuration Variables. You should be able to do so by clicking 'configure variables' in the process step.
I don't think it being deployed via Octopus is all that relevant here. Generally, a .NET WebJob is able to access Azure App Setting using standard configuration API.
If that is not working for you, please update your question to clarify what you tries, and specifically what didn't work.

Pass job name and build number to cloudbees application

I want to be able to use the job and build number within my cloudbees application (i.e access it as an environment variable).
In the application description, I can use "${JOB_NAME} #${BUILD_NUMBER}", but is this also possible somehow within the environment override fields?
I want to be able to set something like:
Name: runningversion
Value: ${JOB_NAME} #${BUILD_NUMBER}
I am assuming you are using the CloudBees Deployer plugin to deploy your application to our RUN#cloud service.
If that is the case then you can achieve exactly what you want with the Override Environment section. You just need to do something like this:
The in-line help for the Value field even indicates that it
Supports ${} style token macro expansion
As a hint to let you know that you can do what you are trying to do... so if it doesn't work then there is a bug!
Those Override Environment name-value pairs should be available, at least, as OS level environment variables and for the Java based ClickStacks (e.g. Tomcat, JBoss, Glassfish, Play, etc) they should also be available as Java System Properties but that can require that the ClickStack is written to provide that support (the well known ones produced by CloudBees should)

SSIS package: How to insert/update data into a Sql server's table by calling a web service in a ssis package?

Is there any way to call a web service in a ssis package in order to insert some data into a table within SQL Server? How? any sample or guidance please?
I assume by your question, you are referring to using a web service as a destination for a data flow? I inherited a series of packages that integrate with our MS CRM site. As designed, these packages are a horrible fit for the SSIS paradigm but that's my burden to bear...
These packages generally fit the form of Source (OLE DB or Flat File) fed to a Script Task (destination). I don't know that providing all the code of a particular task would be enlightening. It's simply invokes the web service for each row sent into it. RBAR is not what SSIS or set based languages are made for but you can certainly do it.
The Script transformation will have a web reference (ours is named CrmSdk) to the service.
Declare an instance of the service as a member of ScriptMain.
Instantiate that service in your script, passing credentials as needed. Most likely in your PreExecute method
Make calls to the web service in your Input0_ProcessInputRow method using the Row.Column1 notation. Do be aware of nulls and how the web service handles them. Our code uses service.CompanyName = Row.CompanyName_IsNull ? string.Empty : Row.CompanyName;
If your intention is to use a web service at the Control Flow level, be aware that the default Task has a hard coded 5 minute timeout. Not sure if that's still the case, but in the 2005 package I was dealing with, we had to use a straight Script Task to communicate with our webservice (it was cleansing millions of rows of address data in batch fashion) to bypass the timeout issue. Reference to timeout property