Skip to content

Natalia issue6 temp #61

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

Merged

Conversation

nataliagourova
Copy link
Contributor

@nataliagourova nataliagourova commented Jan 21, 2021

Note: this PR repurposed a branch on a forked repo where all commit dates are retained.

Sprint1 Task4
This feature implements the API endpoint for getting, creating, updating and deleting a task when a userId and a taskId are passed in by the client.

Testing instructions:

  • preview navigate to nsc-functionsapp-team1
  • there have been issues with the group deployment, while we are fixing them, navigate here and start the function if it happens to be stopped, then proceed
  • select "functions" on the left hand side blade
  • click on HttpTriggerAPIUsersIdTaskId function
  • select "Code + Test" on the left hand side blade - the code appears
  • select Test/Run in the middle of the top-side menu - a parameters window appears
  • Select the appropriate HTTP method
  • Click on "+Add parameter" two times
  • Enter two parameters {names} and {values} like so:
    userId 1
    taskId 18
  • Button "RUN" lights up - click on it
  • Results are displayed in the Output Window
    Note: GET and UDPATE are further along than POST and DELETE. You will therefore see different response messages

GET input/output
Screen Shot 2021-01-20 at 5 14 45 PM
Screen Shot 2021-01-20 at 5 14 56 PM
UPDATE input/output
Screen Shot 2021-01-20 at 5 15 16 PM
Screen Shot 2021-01-20 at 5 15 42 PM
POST input/output
Screen Shot 2021-01-20 at 5 15 55 PM
Screen Shot 2021-01-20 at 5 16 07 PM
DELETE input/output
Screen Shot 2021-01-20 at 5 16 33 PM
Screen Shot 2021-01-20 at 5 16 45 PM

Steps taken to complete this task:

Date Activity Time Spent
Jan 8-10 AZURE odbc connection review 4 hours
Jan 10-18 Azure Functions in Python documentation review 6 hours
Jan 9 Setting up the local environment for testing 4 hours
Jan 9-10 Deployment of own test rg group, database, function app 3 hours
Jan 13-20 Development/debugging/testing/deployment 10 hours
Jan17-20 Team check-ins, documentation creation, git work, other misc 4 hours
Total: 27 hours

If you choose to test the function code on your local machine /deploy to cloud:
ensure you have access to Azure
clone the repository
ensure that code for the other API functions is present as there are some shared modules across the functions *
install python 3.6-3.8

  • install required libraries (azure.functions, pyodbc)
  • install Azure Functions Core Tools and in Visual Studio Code
  • install Python and Visual Studio Code with the Azure Function extension
    -set up the environ (venv and vscode files are not part of the available code)
    -update yourlocal.settings.jason file to include these values, which will permit connecting to the database deployed to the cloud:
    {
    "IsEncrypted": false,
    "Values": {
    "AzureWebJobsStorage": "",
    "FUNCTIONS_WORKER_RUNTIME": "python",
    "ENV_DATABASE_USERNAME": "username",
    "ENV_DATABASE_PASSWORD": "xyz",
    "ENV_DATABASE_NAME": "xyz",
    "ENV_DATABASE_SERVER": "xyz"
    }
    }

-run your code with the appropriate venv Python interpreter

when testing in Postman, input same params as recommended above (userId =1, taskId =18)
note that some values such as userId =1, taskId =1 are not available in the database

To deploy in the cloud, create a resource group, a functions app, add records in the functions app configuration file to contain
same information as above, for
"ENV_DATABASE_SERVER"
"ENV_DATABASE_NAME"
"ENV_DATABASE_USERNAME"
"ENV_DATABASE_PASSWORD"
Deploy the function directly from VSCode via the Azure extension

For additional troubleshooting, see documentation for other API endpoints within the project, e.g. here

… the API method called, url parameters entered and database query result
…ql query for GET method, passed in url parameters
… encapsuled db connection block in its own function
@theKunte theKunte requested review from lbrown51 and theKunte January 21, 2021 05:47
@theKunte
Copy link
Contributor

I am currently unable to test the branch in Azure. It says it is connected but I get an 500 Error. This might have to do with the resource group. All other code was able to retrieve data from ( The other http trigger)
taskissue

Copy link
Contributor

@theKunte theKunte left a comment

Choose a reason for hiding this comment

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

I am still unable to run the function on Azure. locally I get a response, but I am not sure how to test it. Natalia's documentation on her PR is pretty detailed and it makes sense. It seems like she is able to run the deployed function on her own resource group. I am not sure why I am unable to add a test after deployment on azure. I would still approve this PR, but in the next sprint, we will have to address this issue and fix it in the next sprint.
I tested the API endpoints differently and was only focused to receive JSON data from a GET response.

@nataliagourova
Copy link
Contributor Author

nataliagourova commented Jan 21, 2021

NOTE: this is a sanitized PR that stems from a closed unresolved conflicts PR containing all appropriate dates for the commits (unavailable in this PR)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
task New task, feature or request team1 Issues for Practicum Team 1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task] 4 Implement Azure Function for users/{user_id}/tasks/{task_id} API
3 participants