0

I have to run SQL Azure Powershell script in SQL Azure query editor. I have done run Windows Powershell script in SQL server(Express edition) query editor of my system as

xp_cmdshell 'sqlps -command "$http=New-Object system.Net.WebClient;$http.downloadString(\"url\")"'

It was successfully called the application by the url. But when I try to use same concept in SQL Azure, I come to know there is SQL Azure Powershell. From this poweshell I can call the application by url, for that I need to open SQL Azure Powershell and write the command, I Don't want to do in this way. I want to do the way I did in SQL server that write the query to run the Powershell script, I searched a lot but I don't find how to run the SQL Azure Powershell script in SQL Azure query editor Since It doesn't support the xp_cmdshell.

can any one help me to solve this problem or refer me link where I can find material about SQL Azure Powershell

niren
  • 2,693
  • 8
  • 34
  • 58

1 Answers1

1

You can't execute powershell scripts on the SQL Azure machine because of security related issues. Why do you want to execute a powershell script, what does the script do? Perhaps there is another way of achieving your objective.

CamW
  • 3,223
  • 24
  • 34
  • I need to send http request or trigger external application reside in tomcat server, that's where I used Powershell script in Query editor in my local sql server. – niren Aug 08 '13 at 07:39
  • Is there any other way to trigger application or at least send message to external java application which is there in tomcat server – niren Aug 08 '13 at 07:40
  • Or at least I need to trigger `.bat(windows)/.sh(ubuntu executable's)` file from sql azure. can you help me to find my requirement to work. – niren Aug 08 '13 at 07:47
  • Why do you need to call the http endpoint from SQL? Do you only call it when there is certain data in the database? Is tomcat hosted on an Azure VM? If that is what you're doing then you can use a windows service or Linux cron job to poll the database and make that request when it finds the required data. – CamW Aug 08 '13 at 09:33
  • I have SQL Azure access and dedicated server access. I have tomcat server in dedicated server. My requirement: when ever there is data change in database, the database invoke tomcat's application by http request/ message/ some thing. Note: There is no interaction for user with Tomcat application, he can only update/insert/delete data in database, Database is the one trigger the application. Later on we will try to send data along with http request or with message, but initially we need some thing to run. – niren Aug 08 '13 at 09:54
  • 1
    CLR Stored procs, Extended stored procs and SQL agent are all not available on Azure. So there is no way to get the database to invoke your app. You have 2 options: You can get your app to watch the database every few seconds and take action when it sees new data (using something like http://quartz-scheduler.org/) **OR** you can have a intermediate windows service or cron job which watches the database and invokes your app when it sees new data. Using a cron job or persistent process on your tomcat dedicated server will probably be easiest. – CamW Aug 08 '13 at 10:07
  • Thank you for your information. we decided to have sql server in virtual machine, I hope from there I can able to invoke my app. Can You suggest me which way is better to invoke my app. I know using powershell I can do and OLE automation process to send http request(but the disadvantage is when I use OLE automation process in sql server it often crashes sql server and made it stop). See my posted answer for my question [here](http://stackoverflow.com/questions/17407338/how-can-i-make-http-request-from-sql-server). Can you tell me is there any better to do this? – niren Aug 10 '13 at 07:38