mikhailshilkov / tictactoe

Tic-Tac-Toe with F#, Azure Functions, HATEOAS and Property-Based Tests
MIT License
18 stars 3 forks source link

SImplest way to deploy to Azure Functions? #4

Open dsyme opened 6 years ago

dsyme commented 6 years ago

Hi @mikhailshilkov

I looked at this code - it's great. What's the simplest path to actually deploy to Azure functions, (or run on local development storage)?

When I try

dotnet publish

I get this - I know this probably isn't meant to work (obviously more settings will be required) but I just wonder what's the easiest path. Could we set up a one-click install process that takes us through the deployment actions?

image

mikhailshilkov commented 6 years ago

Hi @dsyme , thanks! Just did a fresh clone, then dotnet publish from solution folder - everything went smooth. dotnet version is exactly the same. The only difference I can see right now - I'm on Windows...

Looks very much like https://github.com/Microsoft/msbuild/issues/1957 but I don't see any ProjectDependencies in my solution file...

dsyme commented 6 years ago

I got a bit further with this:

dotnet publish TicTacToe.Functions/TicTacToe.Functions.fsproj 

But that doesn't actually run locally against azure emulated storage nor publish to Azure.

I also tried just creating an Functions Serverless App on Azure and pointing it at my clone of this github repo, but got this in the Azure activity log. It feels like this is some kind of limitation in Azure Functions F# support, perhaps something I have not yet configured or them using an older version of the dotnet SDK

Build started 2/2/2018 8:34:18 PM.
Project "D:\home\site\repository\TicTacToe\TicTacToe.fsproj" on node 1 (default targets).
D:\Program Files (x86)\MSBuild-15.3.409.57025\MSBuild\Microsoft\VisualStudio\v15.0\FSharp\Microsoft.FSharp.NetSdk.props(3,3): error MSB4019: The imported project "D:\Program Files (x86)\Microsoft SDKs\F#\4.1\Framework\v4.0\Microsoft.FSharp.NetSdk.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. [D:\home\site\repository\TicTacToe\TicTacToe.fsproj]
Done Building Project "D:\home\site\repository\TicTacToe\TicTacToe.fsproj" (default targets) -- FAILED.

Build FAILED.

"D:\home\site\repository\TicTacToe\TicTacToe.fsproj" (default target) (1) ->
  D:\Program Files (x86)\MSBuild-15.3.409.57025\MSBuild\Microsoft\VisualStudio\v15.0\FSharp\Microsoft.FSharp.NetSdk.props(3,3): error MSB4019: The imported project "D:\Program Files (x86)\Microsoft SDKs\F#\4.1\Framework\v4.0\Microsoft.FSharp.NetSdk.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. [D:\home\site\repository\TicTacToe\TicTacToe.fsproj]

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:01.00
Failed exitCode=1, command="D:\Program Files (x86)\MSBuild-15.3.409.57025\MSBuild\15.0\Bin\MSBuild.exe" "D:\home\site\repository\TicTacToe\TicTacToe.fsproj" /p:DeployOnBuild=true /p:configuration=Release /p:publishurl="D:\local\Temp\8d56a7c4e5f56f3"
An error has occurred during web site deployment.
\r\nD:\Program Files (x86)\SiteExtensions\Kudu\70.10129.3231\bin\Scripts\starter.cmd "D:\home\site\deployments\tools\deploy.cmd"
mikhailshilkov commented 6 years ago

To answer your question, to run it you need to have the func CLI tools installed

npm install -g azure-functions-core-tools@core

then you do

dotnet publish
cd TicTacToe.Functions
func start --script-root bin\\debug\\netstandard2.0\\publish
mikhailshilkov commented 6 years ago

To put it into Azure, you need to change the runtime version of your Function App to v2 beta in the settings, and then do CLI (run it from publish folder)

func azure functionapp publish <app name>
dsyme commented 6 years ago

Looks like you need this on Unix:

sudo npm install -g azure-functions-core-tools/@core --unsafe-perm=true --allow-root

https://github.com/Azure/azure-functions-cli/issues/331

dsyme commented 6 years ago

Thanks, making progress. I got the splash screen at http://localhost:7071 in Chrome but looking at the code I expected to be able to fetch http://localhost:7071/leaderboard using the browser. Is that the wrong URL?

dsyme commented 6 years ago

BTW for anyone trying to repeat this, you set the Function App to "Runtime Version v2" here in the Azure Portal:

image

mikhailshilkov commented 6 years ago

/leaderboard is the correct URL. You can compare your results with same URLs on http://tictactoefs.azurewebsites.net

mikhailshilkov commented 6 years ago

You might need to create TicTacToe table in your storage account, I don't remember if Functions do that automatically

dsyme commented 6 years ago

Thanks.

You might need to create TicTacToe table in your storage account

I don't know how to do that on local storage on OSX. Will try to make sure the code creates the table

mikhailshilkov commented 6 years ago

https://azure.microsoft.com/en-us/features/storage-explorer/ claims to be cross-platform

dsyme commented 6 years ago

Looks like the local storage emulator is Windows-only, though there is a 3rd party one for Linux https://docs.microsoft.com/en-us/azure/storage/common/storage-use-emulator

mikhailshilkov commented 6 years ago

Just connect to a real Azure Storage account then?

dsyme commented 6 years ago

@mikhailshilkov Trying that, still had issues - odd. Will take a closer look later

forki commented 6 years ago

yeah I don't get it working as well. getting 404 from function app

mikhailshilkov commented 6 years ago

Puzzled... Do you see the URLs in command line when you run the app?

forki commented 6 years ago

I'm testing it on the function app in the portal i's already not behaving over there

mikhailshilkov commented 6 years ago

I'm afraid I need more details to help. We must be deploying/running the app differently.

forki commented 6 years ago

I create a function app. make it beta. run dotnet publish. use "func azure functionapp publish"

and stuff doesn't work. I know it worked a while ago when I tested it. But does not now.

marc-wilson commented 5 years ago

How would one deploy the function to a specific slot? I tried a couple of things and neither work:

func azure functionapp publish <func name> --slot dev

func azure functionapp publish <func name with slot name>