title: How to run stored procedure using Azure Automation?
body: <p>I´m really new to the Azure platform and maybe this is a dumb question but i haven´t manage to find information about this topic. I really need help with this. I'm deploying a database used by a web service for a university project. In this database I have an stored procedure and need to run it daily.</p>
  
  <p>Found that with Azure Automation you could program or schedule this kind of actions. I "installed" the service and I´m trying to create the "runbook" but don´t know how or what to code in here because I never used PowerShell that much.</p>
  
  <p>Any help provided will be appreciated. Thanks in advance!</p>
  
  <p>EDIT 1: </p>
  
  <p>So I'm trying to use this code to make the magic:</p>
  
  <pre><code> workflow WORKFLOW_NAME
  { 
      param( 
  
      ) 
  
  
      inlinescript { 
          # Define the connection to the SQL Database 
          $Conn = New-Object System.Data.SqlClient.SqlConnection("Data Source=SERVER_NAME.database.windows.net;Initial Catalog=DATABASE_NAME;Integrated Security=False;User ID=USERNAME;Password=PASSWORD;Connect Timeout=60;Encrypt=False;TrustServerCertificate=False") 
  
          # Open the SQL connection 
          $Conn.Open() 
  
          # Define the SQL command to run. 
          $Cmd=new-object system.Data.SqlClient.SqlCommand("exec PROCEDURE_NAME", $Conn) 
          $Cmd.CommandTimeout=120 
  
          # Execute the SQL command 
          $Da=New-Object system.Data.SqlClient.SqlDataAdapter($Cmd) 
  
          # Close the SQL connection 
          $Conn.Close() 
      } 
  }
  </code></pre>
  
  <p>The thing is that when I save the RunBook and publish it, it says there is no errors. When I run the RunBook it starts and finish sending no errors nor exceptions, so you could expect it did the work right?, but when consulting the database there is no modifications in the tables the procedure is intended to modify. What could be the error in this? what am I doing wrong?</p>
  
  <p>I took the reference code from <a href="https://gallery.technet.microsoft.com/scriptcenter/How-to-use-a-SQL-Command-be77f9d2#content" rel="noreferrer">https://gallery.technet.microsoft.com/scriptcenter/How-to-use-a-SQL-Command-be77f9d2#content</a> , personalized it and got rid of the "param" because the RunBook when started, never asked for any entry parameters, so I decided to go with the full connection string. I'm using the same connection string as my c# project, which connects and works perfectly. </p>
  
  <p>I'm using the "new" azure interface, don't know if this could be of any importance in this regard.</p>
  
  <p>Again, thank you for any help you could provide.</p>