This project was started as a Web Service to answer my UK cellphone number whilst living in Australia. I had moved the number onto Twilio so I decided to build an Azure function that would have a request sent to it everytime my number would be called.
- .NET 8 SDK installed (Download .NET SDK)
- Ngrok Installed (For local builds) (Download NGROK)
- Azure subscription (Create Azure account)
- Twilio subscription (Create Twilio account)
- Clone the repository:
git clone https://github.com/antland01/CloudAnswerPhone
- Navigate to the project directory:
cd CloudAnswerPhone
- Restore dependencies:
dotnet restore
- Set up Azure Function CLI (Azure Functions Core Tools):
npm i -g azure-functions-core-tools --unsafe-perm true
- Azure Resources Setup:
- Create an Azure Function App in the Azure portal.
- Obtain the connection string and URL for your Azure Function
- Twilio Setup:
- Sign up for Twilio if you haven't already - (Create Twilio account)
- Also setup the numbers you will use with the service to use it to its full you will need at least 2 numbers one to send the notifications and one to call to.
- Go to the Account Info on the main page and note down the Account SID and the Auth Token as they will both be used for the Function.
- Local Configuration:
- Create a local.settings.json file in the project root.
- fill in with the below template.
{ "IsEncrypted": false, "Values": { "AzureWebJobsStorage": [Connection String from Azure for the Azure Function], "FUNCTIONS_EXTENSION_VERSION": "~4", "TwilioAuth": [Auth Token from Your Twilio Account], "TwilioSID": [SID from Your Twilio Account], "MyNumber": [Number you want the Text messages to go to when you get a call], "MyNotificationNumber": [Twilio Number for sending notifications from], "FunctionURL": [The URL of the Function, Either get this from Azure or NGROK], "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated" } }
- Run the Azure function locally. Note down the port number being used for the function AnswerPhone.
dotnet build func start
- Run NGROK with the port number used, Default is 7071.
ngrok.exe http 7071
- Go to Twilio and navigate to thw phone number you wish to use and set the webhook URL to NGROKURL/api/AnswerPhone
To deploy the Azure Function to Azure, you can use various methods including:
- Azure DevOps Pipelines
- GitHub Actions
- Visual Studio Publish
- Azure CLI
- Azure Portal
Choose the deployment method that best fits your workflow and follow the appropriate steps for deployment.