Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build and deploy Azure web jobs #613

Merged
merged 5 commits into from
Jan 3, 2015
Merged

Build and deploy Azure web jobs #613

merged 5 commits into from
Jan 3, 2015

Conversation

TWith2Sugars
Copy link
Contributor

Deploying webjobs via msdeploy is awkward for my self so I built this bit of code to build a zip of the files in the release folder and and push it via the rest api that Azure Websites have.

This makes use of the zip controller.

It works but is a bit rough in some places, for example it dependent on "/bin/release" for the location of the dlls to zip up.

This is an example of how you'd call it:

// Define webjobs/website
let webJobs = [{Name = "webjob1"; JobType= WebJobType.Continuous; Project ="WebJobProject1"}
                       {Name = "webjob2"; JobType= WebJobType.Triggered; Project ="WebJobProject2"}]
let webSite = {WebSite.Url = Uri("https://yoursite.scm.azurewebsites.net")
                      UserName = "$yoursite"
                      Password = "somepassword"
                      WebJobs = webJobs }

// Targets to build/deploy

Target "PackageWebJobs" (fun _ ->
    PackageWebJobs(fun p -> {p with OutputPath = "bin"}) [webSite]
)
Target "DeployWebJobs" (fun _ ->
    DeployWebJobs(fun p -> {p with OutputPath = "bin"}) [webSite]
)

///
/// - `setParams` - Function used to overwrite webjobs outputpath.
/// - `webSites` - The websites and webjobs to build zips from.
let BuildZip setParams webSites =
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should call this package rather than build?

@TWith2Sugars
Copy link
Contributor Author

Other problems could be in the package section it doesn't package folders :\

///
/// - `setParams` - Function used to overwrite webjobs outputpath.
/// - `webSites` - The websites and webjobs to deploy.
let DeployWebJobs setParams webSites =
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I take in a list of web sites or just one and let the users handle multiple? All this would mean is less code as deployWebJobsToWebSite would be the deploy method.

@raymens
Copy link
Contributor

raymens commented Dec 22, 2014

I'd really like it to be able to deploy from any location, as my binaries are not in the bin/release folder (currently).

@TWith2Sugars
Copy link
Contributor Author

So an option in the params to specify the zip/dll location would be better? Perhaps default it to bin/release?

@raymens
Copy link
Contributor

raymens commented Dec 22, 2014

Yes, the source aswell as the target location of the zipping process. I wouldn't mind any defaults, as long as it's not that hard to change the defaults.

Now packages all files/folders as well
@TWith2Sugars
Copy link
Contributor Author

Right, made the change to specify the directory to zip.

Doesn't feel right being part of the params type ,might be better with the webjob type so that each job could potentially have a different directory location to zip.

@TWith2Sugars
Copy link
Contributor Author

Could make each WebJob type specify the directory to zip and the location of the zip file. This would give us the most flexible solution I think.

…ectory/package location.

This means we can get rid oft he set params from package/deploy.

Removed the uri type extension as it's not used any more.
@TWith2Sugars
Copy link
Contributor Author

I've made a change so that each webjob is responsible for it's own dll location/package location. This means there is a bit more emphasis on the end user to specify locations but this does give more flexibility.

This is what the code would look like to call it now:

// a function to crete webjobs based on my projects structure
let private createWebJob site name jobType project = 
    let path = jobTypePath jobType
    { Name = name
      JobType = jobType
      Project = project
      DirectoryToPackage = sprintf "src/%s/bin/Release" project
      PackageLocation = sprintf "bin/%s/webjobs/%s/%s.zip" site path project }

let webJobs site = [createWebJob site "webjob1" WebJobType.Continuous "WebJob1"
                    createWebJob site "webjob2" WebJobType.Triggered "WebJob2"]

let site = Uri("https://yoursite.scm.azurewebsites.net")
let webSite = {WebSite.Url = site
               UserName = "$yoursite"
               Password = "password"
               WebJobs = webJobs site.SubDomain }

Target "PackageWebJobs" (fun _ ->
    PackageWebJobs [webSite]
)
Target "DeployWebJobs" (fun _ ->
    DeployWebJobs [webSite]
)

@raymens
Copy link
Contributor

raymens commented Dec 23, 2014

That would make it usable for my (and others) usecase(s), I like it.

@forki
Copy link
Member

forki commented Dec 26, 2014

Is it ready to merge?

@TWith2Sugars
Copy link
Contributor Author

If every one is happy then yeah

forki added a commit that referenced this pull request Jan 3, 2015
Build and deploy Azure web jobs
@forki forki merged commit 68a7835 into fsprojects:master Jan 3, 2015
@forki
Copy link
Member

forki commented Jan 3, 2015

cool thanks!

@dsyme
Copy link
Collaborator

dsyme commented Feb 19, 2015

Could you add documentation for this as well, and submit a link to https://github.com/fsharp/fsfoundation/edit/gh-pages/guides/cloud/index.md?

@TWith2Sugars
Copy link
Contributor Author

Something along the lines of: http://fsharp.github.io/FAKE/typescript.html ?

@forki
Copy link
Member

forki commented Feb 20, 2015

Yes that would be great

@TWith2Sugars TWith2Sugars deleted the AzureWebJobs branch February 23, 2015 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants