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

Azure Functions Cli #477

Closed
wants to merge 19 commits into from
Closed

Azure Functions Cli #477

wants to merge 19 commits into from

Conversation

ahmelsayed
Copy link
Contributor

@ahmelsayed ahmelsayed commented Jul 7, 2016

> npm i -g azurefunctions
Local -> Azure:
> mkdir functions
> cd functions
> func init
> func new # launches yoeman generator (assume functionName=HttpCSharp)
>  func run HttpCSharp -f file.json
> git commit -am "First function"
> func new functionapp MyNewAwesomeFunctionApp -l WestUS
> func list functionapps # displays the git url for the function app
> func user # lets me reset publishing user.
>  git push https://MyNewAwesomeFunctionApp.scm.azurewebsites.net/ master
> func open MyNewAwesomeFunctionApp # launches default web browser with deep link to portal
Azure -> Local:
> func login
> func list functionapps # displays a list of function apps
> func switch-tenants # displays a list of tenants
> func switch-tenants <tenantId> 
> func list functionapps
> git clone https://MyNewAwesomeFunctionApp.scm.azurewebsites.net
> cd MyNewAwesomeFunctionApp
> func fetch secrets MyNewAwesomeFunctionApp
> func run FunctionName # then you go in the portal and switch to local
> func help
Azure Functions CLI 0.1
Usage: func [verb] [Options]

   config          get and set global cli config options
   fetch           fetches function app secrets
   login           Clears login cache and prompts for a new login
   logout          Clears login cache
   open            Launch default browser with link to the function app in https://portal.azure.com
   switch-tenants  List and switch current tenant for the Cli
   init            Creates .gitignore, and host.json. Runs git init .
   set             Not yet Implemented
   new             Handle creating a new function or function app
   run             Run the specified function locally
   user            Helps manage publishing username
   web             Launches a Functions server endpoint locally
   list            Lists function apps in current tenant. See switch-tenant command


Tip: run func init to get started.
>  azf help new
Azure Functions CLI 0.1
Usage: func new [function/functionApp] <functionAppName> [Options]

   <newOption>          [Function/FunctionApp/StorageAccount/Secret]
   <functionAppName>    (Required)
   -s/--subscription    Subscription to create function app in
   -l/--location        Geographical location for your function app

Tip: run func init to get started.
>  func help run
Azure Functions CLI 0.1
Usage: func run <functionName> [Options]

   <functionName>    (Required)
   -t/--timeout      Time to wait until Functions Server is ready in Seconds
   -c/--content      In line content to use
   -f/--file         File name to use as content
   -d/--debug        Attach a debugger to the host process before running the function.

Tip: run func init to get started.
>  func help list
Azure Functions CLI 0.1
Usage: func list FunctionApps [Options]

Usage: func list Secrets [Options]

   -a/--show    Display the secret value

Usage: func list StorageAccounts [Options]

Usage: func list Tenants [Options]

Tip: run func init to get started.
>  func help user
Azure Functions CLI 0.1
Usage: func user <userName> [Options]

   <userName>    (Required)

Tip: run func init to get started.
>  func help config
Azure Functions CLI 0.1
Usage: func config <name> <value> [Options]

   <name>     (Required)
   <value>    (Required)

@dnfclas
Copy link

dnfclas commented Jul 7, 2016

Hi @ahmelsayed, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution!
You've already signed the contribution license agreement. Thanks!

The agreement was validated by .NET Foundation and real humans are currently evaluating your PR.

TTYL, DNFBOT;

@awolf
Copy link

awolf commented Jul 7, 2016

Hi @ahmelsayed, as a .Net developer doing Node development, this is the interface I would be most comfortable with. Especially since I use a Mac and Atom for my development environment.

The command are logical, well thought out and not surprising. That's always a plus.

@ahmelsayed ahmelsayed changed the title [Help] azure-webjobs-sdk-script-command-line-interface Azure Functions CLI Jul 13, 2016
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
Copy link
Member

Choose a reason for hiding this comment

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

Can you name this project (and related projects) WebJobs.Script.CLI? That leads to less confusion with the existing 2 hosts we have, which are about hosting functions, not CLI stuff.

@mathewc
Copy link
Member

mathewc commented Jul 16, 2016

You'll want to add entries to WebJobs.Script.proj so this is building on the CI machine and tests are running. @fabiocav can also help you make sure artifacts are being generated as part of our AppVeyor build (we'll want to start including these in our milestone release drops, e.g. here).

@mathewc
Copy link
Member

mathewc commented Jul 16, 2016

Also you'll want to start a wiki page on how to use the CLI :) At least getting people started.

{
public class FileTracer : TraceWriter
{
private Collection<TraceEvent> _traces = new Collection<TraceEvent>();
Copy link
Member

Choose a reason for hiding this comment

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

Unused?

@christopheranderson
Copy link
Contributor

Still a failure:

image

@ahmelsayed
Copy link
Contributor Author

can you try npm cache clean?

@christopheranderson
Copy link
Contributor

Still having issues running this on my machine. I'm getting an error thrown from Ln23 of ConsoleApp.cs. This repros on 0.0.9 as well.

public static void Run<T>(string[] args, IDependencyResolver dependencyResolver = null)
        {
            Task.Run(() => RunAsync<T>(args, dependencyResolver)).Wait();
        }
Exception thrown: 'Microsoft.WindowsAzure.Storage.StorageException' in Microsoft.WindowsAzure.Storage.dll
Exception thrown: 'System.InvalidOperationException' in mscorlib.dll
Exception thrown: 'System.AggregateException' in mscorlib.dll
Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll
Exception thrown: 'Microsoft.WindowsAzure.Storage.StorageException' in Microsoft.WindowsAzure.Storage.dll
The thread 0xa20 has exited with code 0 (0x0).
Exception thrown: 'Microsoft.WindowsAzure.Storage.StorageException' in Microsoft.WindowsAzure.Storage.dll
Exception thrown: 'System.InvalidOperationException' in mscorlib.dll
Exception thrown: 'System.AggregateException' in mscorlib.dll
The program '[14168] Func.vshost.exe' has exited with code -1 (0xffffffff).

Looks like Storage issues? I tried setting environment variables/etc.

I am also still getting install issues with 0.0.10, but I manually grabbed the tarball, unzipped it, and placed it in my global npm. It runs fine, except for web/run.

> func run .\httptest\
Response Status Code: ServiceUnavailable

It's quite hard to tell if I'm doing something wrong or if it's just not functional. Attaching a debugger only kept me going through a loop where I was getting the above exceptions being thrown.

Ideas for next steps?

@ahmelsayed
Copy link
Contributor Author

are you running Func.vshost.exe or func.exe? also it might be a legitimate issue. Maybe I have some storage dll globally in my gac or something and it's not included in the package.

@ahmelsayed
Copy link
Contributor Author

Also the web command is the only command that actually loads the host, so it's the one most likely to fail because of a missing dependency.

@christopheranderson
Copy link
Contributor

I'm not running func.exe/func.vshost.exe directly in either case. In one, I attached the debugger to the source in your fork to find where the exception was being thrown. In the other, it was just the npm package that gets installed from npm registry. I tried attaching to the host to see if I can find in more detail what was causing the host to not start, but symbols weren't loading for the script.host

@christopheranderson
Copy link
Contributor

Also, I realized I didn't give verbose logs for the npm install issue:

C:\Users\chrande> npm cache clean
C:\Users\chrande> npm install -g azurefunctions --verbose
npm info it worked if it ends with ok
npm verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
npm verb cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
npm verb cli   'install',
npm verb cli   '-g',
npm verb cli   'azurefunctions',
npm verb cli   '--verbose' ]
npm info using [email protected]
npm info using [email protected]
npm verb request uri https://registry.npmjs.org/azurefunctions
npm verb request no auth needed
npm info attempt registry request try #1 at 10:40:23 AM
npm verb request id f95c9ebcb62b4b9a
npm http request GET https://registry.npmjs.org/azurefunctions
npm http 200 https://registry.npmjs.org/azurefunctions
npm verb headers { server: 'CouchDB/1.5.0 (Erlang OTP/R16B03)',
npm verb headers   etag: '"27SBPYMH9HQDLMHKR46X8VOFY"',
npm verb headers   'content-type': 'application/json',
npm verb headers   'content-encoding': 'gzip',
npm verb headers   'cache-control': 'max-age=300',
npm verb headers   'content-length': '1796',
npm verb headers   'accept-ranges': 'bytes',
npm verb headers   date: 'Tue, 09 Aug 2016 17:40:27 GMT',
npm verb headers   via: '1.1 varnish',
npm verb headers   age: '0',
npm verb headers   connection: 'keep-alive',
npm verb headers   'x-served-by': 'cache-sjc3622-SJC',
npm verb headers   'x-cache': 'MISS',
npm verb headers   'x-cache-hits': '0',
npm verb headers   'x-timer': 'S1470764427.365202,VS0,VE142',
npm verb headers   vary: 'Accept-Encoding' }
npm verb get saving azurefunctions to C:\Users\chrande\AppData\Roaming\npm-cache\registry.npmjs.org\azurefunctions\.cach
e.json
npm verb correctMkdir C:\Users\chrande\AppData\Roaming\npm-cache correctMkdir not in flight; initializing
npm verb makeDirectory C:\Users\chrande\AppData\Roaming\npm-cache creation not in flight; initializing
npm verb makeCacheDir UID & GID are irrelevant on win32
npm verb cache add spec azurefunctions
npm verb addNamed "latest" is being treated as a dist-tag for azurefunctions
npm info addNameTag [ 'azurefunctions', 'latest' ]
npm verb addNameTag registry:https://registry.npmjs.org/azurefunctions not in flight; fetching
npm verb get https://registry.npmjs.org/azurefunctions not expired, no request
npm verb addNamed "0.0.10" is a plain semver version for azurefunctions
npm verb addRemoteTarball https://registry.npmjs.org/azurefunctions/-/azurefunctions-0.0.10.tgz not in flight; adding
npm verb addRemoteTarball [ 'https://registry.npmjs.org/azurefunctions/-/azurefunctions-0.0.10.tgz',
npm verb addRemoteTarball   '51f6bce1e29f4d037421255b9b370822e75605a3' ]
npm info retry fetch attempt 1 at 10:40:24 AM
npm info attempt registry request try #1 at 10:40:24 AM
npm http fetch GET https://registry.npmjs.org/azurefunctions/-/azurefunctions-0.0.10.tgz
npm http fetch 200 https://registry.npmjs.org/azurefunctions/-/azurefunctions-0.0.10.tgz
npm verb addTmpTarball C:\Users\chrande\AppData\Local\Temp\npm-4228-e4681199\registry.npmjs.org\azurefunctions\-\azurefu
nctions-0.0.10.tgz not in flight; adding
npm verb addTmpTarball already have metadata; skipping unpack for [email protected]
npm verb correctMkdir C:\Users\chrande\AppData\Roaming\npm-cache correctMkdir not in flight; initializing
npm verb afterAdd C:\Users\chrande\AppData\Roaming\npm-cache\azurefunctions\0.0.10\package\package.json not in flight; w
riting
npm verb correctMkdir C:\Users\chrande\AppData\Roaming\npm-cache correctMkdir not in flight; initializing
npm verb afterAdd C:\Users\chrande\AppData\Roaming\npm-cache\azurefunctions\0.0.10\package\package.json written
npm ERR! cb() never called!
C:\Users\chrande>

It doesn't look like it's happening in your code, but I've not having this happen on any other package I've tried lately.

@christopheranderson
Copy link
Contributor

I found the issue with run/web not working - I had a environment variable on all of my machines from a previous experiment which was being picked up and was broken. :) Works nicely now. Having a blast!

@christopheranderson
Copy link
Contributor

That probably does highlight some of the issues with our current model for running the host in background - we need a better debugging experience for host issues.

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.

7 participants