question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Executing a script

See original GitHub issue

I have a few questions, because the current documentation seemed a bit thin. I’d like to deploy a VM and an Azure SQL database by Farmer. Very basic software architecture. For that, I need to execute a few scripts:

  1. Virtual Machine,

    • Execute cmd/bat/shell-script. That is possible, but can that be done by Farmer?
      • Install Chocolatey @powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
      • Install a few programs like choco install dotnet4.7.2 -y
      • A way to transfer a few files. By installing SSH I guess?
      • Configure Windows firewall, e.g.: netsh advfirewall firewall add rule name="Open Port HTTPS" dir=in action=allow protocol=TCP localport=443
      • Install certificate (certutil) and apply certificate to the port: netsh http add sslcert ipport=0.0.0.0:443 certhash=123abc... appid=abc124...
      • Create a service sc create MyService binPath= c:\path\myservice.exe
      • …and set it to auto-start: sc config "MyService" start= auto
    • I also need to configure the Azure side Network interface for the VM, I couldn’t find Farmer command for that.
    • Set a static IP for VM. I guess this is already supported.
  2. Deploy the Azure Database.

    • Create a new login.
    • Execute an *.sql-script that creates the tables, and inserts some basic data. Azure supports that, but can that be done with Farmer?
    • For the database version control, I’m using VisualStudio SQL Server Database Project (*.sqlproj). Is that messing my architecture-as-code?

What is the preferred way to do these with Farmer?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
isaacabrahamcommented, Jun 30, 2020

VMs

  1. Scripts - you can run a post-deployment script on a VM in an ARM template. We haven’t exposed that yet in Farmer but there’s no reason why we couldn’t - I suggest raising an issue.
  2. Transferring files - we could build a post-deploy task to upload files from the local machine onto the VM. The pure ARM way is to upload files into a storage account first and then reference them in the ARM template. However, this requires a storage account to have been already created and the files uploaded. An alternative is to upload via Azure CLI or SSH - again, Farmer could wrap this up; it’s what we do for app service.
  3. Firewall - this should be possible in ARM, I suggest looking through the docs - if it’s there, we can expose it.
  4. I believe that static IPs are already supported.

Databases

  1. I don’t know if you can create separate logins within ARM - I believe it’s just the standard admin login. Again, can you check the ARM docs for SQL?
  2. When you say “Azure can do that” - do you mean the portal? The portal uses all sorts of different things; Farmer is essentially a wrapper around what ARM templates support plus some extensions that wrap around the Azure CLI for things that ARM doesn’t support.

Database version control and deployments are a separate concern to Farmer - it shouldn’t impact infrastucture-as-code at all (indeed, we’re using dbprojects right now with Farmer - it should just work.

0reactions
isaacabrahamcommented, Jul 2, 2020

This has now been released.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to execute a shell script in Linux
Step 1 – Open the terminal · Step 2 – Write the shell script using an editor · Step 3 – Make the...
Read more >
How To Run the .sh File Shell Script In Linux / UNIX
Type the following command cd /home/username/Desktop/scripts (again substituting the actual user name in place of username). The command ls and ...
Read more >
How To Execute a Command with a Shell Script in Linux
Creating and Running a Basic Shell Script · Press ESC · Type : (colon character) · Type wq · Press ENTER.
Read more >
How to Run a Shell Script in Linux [Essentials Explained]
Method 1: Running a shell script by passing the file as argument to shell. The first method involves passing the script file name...
Read more >
SH - Bash Shell Script File
Open the Linux terminal and go to the directory where the SH file is located. · By Using chmod command, set execute permission...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found