How do I run an executable from an SQL Job in Azure? - sql-server

I have a SQL Server managed instance in Azure, which has a job. The job has several steps to export Excel files to a shared folder. The last step of the job should execute the Sharepoint Uploader app - an app that uploads the Excel files to a Sharepoint online library.
I am able to execute the Sharepoint Uploader on its own, since it is hosted in a virtual machine. However, I am looking to have the last step of the SQL Job to run the Sharepoint Uploader.
Azure {SQL Server instace: {Job: [Step1, Step2, Sharepoint Uploader step]}
| |
V V
Shared folder {Excel files} VM {Sharepoint Uploader} -> Upload files to
Sharepoint Online
Appreciate any help

Related

Azure Devops deploying web app to a server - how to also update database

We have a web app which due to budgetary reasons is running on a windows VM (IIS) with its database also running in SQL Server on the same server.
We have a build pipeline set up in Azure Devops which builds the web app and then creates an idempotent SQL migration file (We use Entity Framework), both the compiled app and the SQL file are copied into the build artefact.
We then have a release pipeline which deploys the web app into IIS on the server.
What I cant figure out is how to get the SQL file run into the database.
I have tried the "SQL Database Deploy" task but that seems to only want a .dacpac file, or the path of a SQL file which is already on the server - I dont seem to be able to give it a file that exists on the build machine to execute remotely.
I know that because we are using EF I could just make the application do its migrations on startup but that means that the app needs to run as a user with schema privileges which we don't really want, currently the app is only a data reader/writer.
Is there some mechanism that I can take the SQL script from the build artefact and run it on the remote VM? If not, what are my options for getting the file onto the VM so that I can run it using the "SQL Database Deploy" task? I don't want to deploy it with the web app as although its a small risk we don't want it lingering in a public folder.
Any help appreciated.

SSIS - SharePoint - Network Path Not Found

I'm using SSIS to upload a PDF from SSRS into a SharePoint 2010 library. When I run the package in SSDT, it uploads as intended. However, when I deploy to the SSIS Catalog and run the package using a proxy account under SQL Server Agent, I receive the following error:
Network path was not found
I have verified my proxy account can post to the SharePoint site as the permissions are set up correctly. My belief is SSIS is not even trying to authenticate with the SharePoint site (maybe trying to connect anonymously?).
The code that uploads the PDF is located below. It authenticates the user to SSRS successfully, but not to SharePoint. The path that it uploads to is a UNC path. How do I get it to authenticate to a UNC path? A thought was to map a drive but that seems like a hack and may not be as reliable.
Dim httpCon As ConnectionManager = Dts.Connections("DDM Report Server")
Dim clientConn As HttpClientConnection = New HttpClientConnection(httpCon.AcquireConnection(Nothing))
clientConn.ServerURL = Dts.Variables("$Package::DDM_ReportServer").Value.ToString() & Dts.Variables("Report_Filename").Value.ToString()
clientConn.DownloadFile(Dts.Variables("$Package::SharePoint_Delivery_Location").Value.ToString() & Dts.Variables("PDF_Name").Value.ToString(), True)
I finally figured this out yesterday. Hannover First, you were onto something. In SSIS, you use WebClient within a script task to authenticate to the SharePoint site using the URL instead of the UNC Path. WebClient has everything you need to authenticate.

How to configure Azure File Storage to access from Windows Service

We are developing and SSIS service to import some data in Excel and CSV files in Azure. For uploading the files we have chosen Azure File Storage and we are running the SSIS packages on a VM. For picking up the files from file storage, we have mapped the File Storage as mapped network drive on the VM. This works file when we manually trigger the SSIS jobs. However, this fails when running as SQL Server Agent job. As far as I understand, the mapped drives are per user and they do not work for service account used for SQL Server Agent. Is there a way by which we can access the file storage in SSIS packages as SQL Agent Jobs?
I found this page but this is for basic windows network file sharing. Does not work for us as we also need to use the Shared Access Key for Azure File Storage.
I solved the problem using this solution.
Add credential via cmd not via the GUI

Visual Studio web and SQL publish

Here's the scenario:
MVC web project
Three MS SQL Server database projects
One of the databases must be populated with lookup tables
Other tables are user data and don't need data uploading
GoDaddy hosting
Visual Studio 2013
I'd like to deploy everything (web project, sql schemas, reference data) to GoDaddy in one fell swoop, but they appear to only offer FTP uploading. When using FTP in the Web Publishing Wizard, it says "Database preview not supported for this method" which I'm taking "method" to mean FTP. I can publish the web project fine in FTP, but of course without the databases the web application generates errors.
So here are my questions
There is a "Web Deploy" publish method listed in the wizard, but GoDaddy has no information on how to set this up. Can this be used with GoDaddy and will it publish DBs also?
How does one configure the project to use the local SQL Server when running on localhost, but when deployed it uses the GoDaddy SQL Servers?
Can the data in the local DB be uploaded as part of the publishing wizard process, or is SQL Server Management Studio the tool of choice?
Thanks!
I don't believe GoDaddy supports WebDeploy. They didn't when I left their service a few years ago. You can talk to them to confirm whether this has changed.
This is the role of Web.Config Transforms. For an intro to the topic, see here; the article is a little out of date and doesn't mention one of the most useful points - you can add transforms for each publish profile, so they're applied according to your publish settings.
You probably can't upload the local DB file. In almost every hosting situation, the SQL server and the web server are two separate machines, and don't share any files (corollary: the web server doesn't have the SQL service installed). One workaround you can try is to publish the DB directly from your own machine. That is, if you can connect to the DB from your machine, you can do a Web Deploy publish to your own machine but it will send the SQL changes to your GoDaddy DB server.
A more advanced workaround for #3:
Set up your FTP publishing settings for your files
Figure out how to publish your DB through WebDeploy only/from the command line (you can refer to here for a sample using WebDeploy from the command line; note this is going from GoDaddy -> Local, but it's trivial to turn it around)
Customize the web publish pipeline to insert an MSBuild target to execute your WebDeploy command line (see here for an example of modifying the pipeline; you can add the target directly in your .pubxml file if you're not intending to use it for multiple projects).
This will give you a single publish profile which will separately publish your files (via FTP) and your DB (via WebDeploy).

Database Usage from Network Server

I am running desktop app that uses mdf file on local path.What if I want to do is that this mdf file should be placed over a network shared folder but network is using Domains and we need password to connect to that folder.Server is running windows Server and dont know if it has installed SQL Express or not.
Q
1-> do server needs to have SQL server Express.
2-> If I publish that project then use on multiple clients that may not have Visual Studio and sql server express but will have Dot Net framework. Will that Database Using application will work
1 - You don't have to use SQL Server Express, but its better than sharing a folder and use a mdf file over network using file sharing, and more trustable.
If your application will be used by one user at time only, you can share a folder on remote server, put the mdf file in there and give read/write access permission on share to the user running your desktop app.
If several users will run the app at the same time and access the database, it won't work because windows will probably lock the mdf file (and if not, your database will get corrupt). Then, you will have to use SQL Server Express and no folder sharing at all.
2 - It will work as long as your clients have SQL Compact Edition, that is installed with the .net framework by default, so you won't have any problems. By the way, if you are planning to all your customers using the same database, all the concerns I answered in question 1 applies here. If multiple users have to connect to the same db file at the same file, you'll have to: 1 - setup a SQL Server Express on client or 2 - publish your sql server express so it can be accessible from outside your network and configure your custumers desktop app to access this server.

Resources