Coder Social home page Coder Social logo

Comments (7)

isaacabraham avatar isaacabraham commented on August 15, 2024

@viktorvan Can you check out the expression-concat branch and try this:

let database = sql { } // create db here...

// either using raw sprintf
let passwordRef = sprintf "concat('connection string stuff ...', %s, '...')" database.AdministratorCredentials.Password.AsArmRef.Value

// or using a custom function that knows how to splice values together correctly.
let passwordRef = concat [ literal "connection string stuff ..."; database.AdministratorCredentials.Password.AsArmRef; literal "..." ]

let fns = functions {
    name "isaacsfunctions"
    setting "sqlpass" passwordRef // just use here...
    depends_on database.ServerName
}

from farmer.

viktorvan avatar viktorvan commented on August 15, 2024

I’ll try that when I am at my computer, but in the mean time I had another crazy idea 😁

Both the alternatives above force the user to know that you have to “concat” arm parameter values. What if, instead, the setting-function hides this away by checking if the value contains any ArmRefs, i.e. if it contains any substrings “[parameters(‘key’)]”. They can then be replaced with the “concat” syntax required by the arm-template schema?

Edit: Or maybe not the setting-function but probably the something in the Writer module.

from farmer.

viktorvan avatar viktorvan commented on August 15, 2024

Ok, I had a chance to try the concat function and it worked fine, but I ended up with this:

let connectionString = 
    concat 
        [ sprintf 
              "Server=tcp:%s.database.windows.net,1433;Initial Catalog=%s;Persist Security Info=False;User ID=%s;Password="
              mySqlDb.ServerName.Value
              mySqlDb.DbName.Value
              mySqlDb.AdministratorCredentials.UserName
          |> literal
          mySqlDb.AdministratorCredentials.Password.AsArmRef
          literal ";MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;" ]

Which I don't think looks very nice though. Like I commented above, it would be nice to have some way to hide the concat away.

I'll sleep on it, and think some more.

from farmer.

isaacabraham avatar isaacabraham commented on August 15, 2024

We can build a helper method on sql db to create a connection string?

from farmer.

viktorvan avatar viktorvan commented on August 15, 2024

Yes, that’s a great solution, much simpler 👍

from farmer.

isaacabraham avatar isaacabraham commented on August 15, 2024

Try now :-)

from farmer.

viktorvan avatar viktorvan commented on August 15, 2024

Yes that works for me. Nicely done. :)

from farmer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.