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

Add slot support for function apps #9550

Merged

Conversation

ankitkumarr
Copy link
Contributor

@ankitkumarr ankitkumarr commented Jun 4, 2019

@panchagnula, would love a review from you.

Fixes #6581, #9126


This checklist is used to make sure that common guidelines for a pull request are followed.

  • The PR has modified HISTORY.rst describing any customer-facing, functional changes. Note that this does not include changes only to help content. (see Modifying change log).

  • I adhere to the Command Guidelines.

Copy link
Contributor

@panchagnula panchagnula left a comment

Choose a reason for hiding this comment

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

Overall LGTM. One thing to do is in the az webapp create can you update it to check if kind is function app & throw a error message to use the new function app commands?

@ankitkumarr ankitkumarr force-pushed the ankikuma/add-functionapp-slot-support branch from c1d8fca to ded1e60 Compare June 5, 2019 23:14
@ankitkumarr
Copy link
Contributor Author

@panchagnula, I have updated the PR to add an error message when use webapp's create command. Please have another look if you don't mind :)

@ankitkumarr ankitkumarr force-pushed the ankikuma/add-functionapp-slot-support branch 2 times, most recently from 750e460 to c0e21c3 Compare June 6, 2019 07:47
@ankitkumarr ankitkumarr force-pushed the ankikuma/add-functionapp-slot-support branch from c0e21c3 to e322308 Compare June 7, 2019 21:47
@panchagnula panchagnula added this to the Sprint 63 milestone Jun 7, 2019
@bigdatamoore
Copy link

Hi @ankitkumarr thanks for implementing this. I was able to check out the repo and test this out and was able to create a slot. I was wondering about the ability to deploy using az functionapp to slots. I believe az webapp has a deployment option (az webapp deployment source config-zip) that has a --slot option. Are you planning on adding the same for the az functionapp deployment commands?

https://docs.microsoft.com/en-us/cli/azure/webapp/deployment/source?view=azure-cli-latest#az-webapp-deployment-source-config-zip

@ankitkumarr
Copy link
Contributor Author

@bigdatamoore, this PR should have addressed that as well. webapp and functionapp use a lot of the same functionality underneath. I turned slots on for all the functionapp commands that should have it. Let me know if you are unable to use it. Thanks!

@ankitkumarr ankitkumarr deleted the ankikuma/add-functionapp-slot-support branch June 13, 2019 21:42
@bigdatamoore
Copy link

@ankitkumarr I was able to deploy a c# function using the az functionapp deployment source config-zip --slot command. I tried it with a python function and got the following error:

(venv) PS > az functionapp deployment source config-zip --resource-group myresourcegroup --name myfunction1 --src test-function.zip --slot staging
Getting scm site credentials for zip deployment
Starting zip deployment. This operation can take a while to complete ...
The command failed with an unexpected error. Here is the traceback:

Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
  File "C:\Users\240721\source\repos\azure-cli\venv\lib\site-packages\knack\cli.py", line 206, in invoke
    cmd_result = self.invocation.execute(args)
  File "c:\users\240721\source\repos\azure-cli\src\azure-cli-core\azure\cli\core\commands\__init__.py", line 561, in execute
    raise ex
  File "c:\users\240721\source\repos\azure-cli\src\azure-cli-core\azure\cli\core\commands\__init__.py", line 619, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "c:\users\240721\source\repos\azure-cli\src\azure-cli-core\azure\cli\core\commands\__init__.py", line 612, in _run_job
    six.reraise(*sys.exc_info())
  File "C:\Users\240721\source\repos\azure-cli\venv\lib\site-packages\six.py", line 693, in reraise
    raise value
  File "c:\users\240721\source\repos\azure-cli\src\azure-cli-core\azure\cli\core\commands\__init__.py", line 589, in _run_job
    result = cmd_copy(params)
  File "c:\users\240721\source\repos\azure-cli\src\azure-cli-core\azure\cli\core\commands\__init__.py", line 298, in __call__
    return self.handler(*args, **kwargs)
  File "c:\users\240721\source\repos\azure-cli\src\azure-cli-core\azure\cli\core\__init__.py", line 467, in default_command_handler
    return op(**command_args)
  File "c:\users\240721\source\repos\azure-cli\src\command_modules\azure-cli-appservice\azure\cli\command_modules\appservice\custom.py", line 296, in enable_zip_deploy
    authorization, timeout)
  File "c:\users\240721\source\repos\azure-cli\src\command_modules\azure-cli-appservice\azure\cli\command_modules\appservice\custom.py", line 2233, in _check_zip_deployment_status
    res_dict = response.json()
  File "C:\Users\240721\source\repos\azure-cli\venv\lib\site-packages\requests\models.py", line 897, in json
    return complexjson.loads(self.text, **kwargs)
  File "C:\Python36\lib\json\__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "C:\Python36\lib\json\decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Python36\lib\json\decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

@ankitkumarr
Copy link
Contributor Author

@bigdatamoore, oh are you on a Linux Consumption plan? Slots aren't yet supported for Linux Consumption, neither is the az functionapp deployment source config-zip command yet. I believe we are tracking support of these scenarios.

@bigdatamoore
Copy link

Ok thanks. That is what I figured. Thanks for the update. I will wait until those are supported. Any idea as to when that could be?

@bigdatamoore
Copy link

@ankitkumarr
Ok nevermind. I was able to get it working. Sorry for the false alarm. The problem I had was that in my staging slot I had the WEBSITE_CONTENTSHARE set to the same value as my production slot. So when I updated one, it was automatically updating the other as well.

I have confirmed that the CLI is working with slots for C# functions. I was able to create a slot, deploy to the slot, and then use the CLI to swap the slots.

@ankitkumarr
Copy link
Contributor Author

@bigdatamoore, thanks for reporting this. I will take a look at your issue later today.

As for the actual code, you did find the correct function enable_zip_deploy. But, it is linked directly to the command here -

. That's why you don't see any code references to it.
The reference you linked is actually for a different command az webapp up that uses the function to deploy.

Anyway, I will try and get a repro to see what's going on.

@ankitkumarr
Copy link
Contributor Author

@bigdatamoore, whoops, I missed you comment. Thanks for verifying. Glad you were able to resolve.

@bigdatamoore
Copy link

@ankitkumarr, can you test out the create slot command and see if it updates the WEBSITE_CONTENTSHARE setting value? When doing this via the portal, the WEBSITE_CONTENTSHARE is automatically appended with a random string. However when doing this via the CLI it is copying the same value that is in the production slot. So that was actually causing the behavior that I was seeing. Probably you will want to add some random string to the end of the existing value so that you don't have these collisions when using the CLI to create slots. This may be by design but I am not sure. Thanks.

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