The information here is about the way to use Azure function Powershell app for fetching information from the RestAPI as well as to send the update on social media.
Being an experienced .net development company, we know the complications of not effectively using a helpful function of an app. To present you the information on how Azure function Powershell app should be used, here we take an example of WioLinkIoT sensors data. These sensors are built upon the information used by Powershell to have environmental data and keep it in the PowerBI. Significantly, the difference lies here in resulting the experimented information on Twitter which uses Powershell TimerTrigger Azure app to do the tasks and encourage a serverless model of Azure functions.
Prerequisites For Using Powershell Azure Function –
Before you start working this app, get following mentioned prerequisite things.
- A Powershell Twitter module
- Use Powershell Gallery to get the module
- Make a folder for Powershell new module. After that, save it to the local machine with “save-module” command as stated below:
Save – module – name InvokeTwitterAPIs – Path c:\temp\twitter
Make A Plan For Function App –
Those who don’t own a Plan for Function app should necessarily create it. For this purpose, search the Functional App from management portal of Azure. Name it, choose usage to make payment as required and choose a right location as well as storage account.
<code class="lang-xml"><configuration> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /> </startup> <appSettings> <add key="StorageConnectionString" value="DefaultEndpointsProtocol=https;AccountName=account-name;AccountKey=account-key" /> </appSettings> </configuration></code>
Make ATwitter App –
Once you get the function app, switch to http://dev.twitter.com for making a brand new app for Twitter which allows one to communicate with this social media network through APIs. Name the Twitter app. During this process, do not think of too much use of URLs and Callback URL. Just, choose Create Twitter Application.
After that, pick the access Tokens and Keys tab and note down the key for API and the Secret API.
Make a button for access token.
Note down the Access token secret as well as Access Token and these two will communicate with your Twitter API.
Make Azure Function Timer Trigger App –
After that, make the TimerTrigger Powershell Azure function. There will be a default schedule for the app which you can change as per your requirement. Now, name the app and click on create. This is who the Azure function TimerTrigger app will be created.
Configure Application Settings Of Azure Function App –
In the newly built Azure function app, you can configure the settings by selecting an option for “configure app settings”. After that, make fresh settings for Twitter Account AccessToken, APIKey, APISecret, AccessTokenSecret and Twitter Account with the values or data you created the app earlier.
Distribution Credentials –
In case you have never configured the distribution credentials in the Azure Function app, then it is the time to try that. While doing that, note down it to upload it in Powershell Twitter module in your app further. Make a note of the distribution username as well as FTP Hostname.
Upload Powershell Twitter Module To Azure Function App –
Make a sub-directory in the function app naming bin and then, upload the Powershell Twitter module with FTP client.
After that, go to the applications settings and start Kudu. Then, pass through the structure folder to find a way to a Powerful Twitter module and write it down.
Validating our Function App Environment
Now, it is a time to code update for replacing sample from creating Trigger Azure feature to get Powershell Twitter module. Add get-help phrases for this Twitter module which will reflect in logs. Then, choose to save and then, run.
Application Function Script –
The application function script shows the data available in the API and also, sends it through a tweet on Twitter.
View A Tweet –
Now, you can see a tweet on your Twitter account from Powershell Azure app.
If you are new to .net or app development, then hire an expert .net agile development company to outsource your Powershell Azure app requirements.