How to expose utility functions within the Azure Portal - utility

I would like to add some operational utility functions to my 100% Azure hosted application together with the ability to manually launch these utilities at arbitrary times in the day via the Azure Portal.
My current Azure technology stack is comprised of Web(Api)Apps, Function Apps, CosmosDb + DocumentDbApi and Azure Storage Queues. The application does not have an HTML front end.
An example of a utility function would be to reset demo tenant data in CosmosDb. One benefit of using the portal UI is that I would not have to authenticate invocation of my utility functions from a remote source.
I code exclusively in C# and to date scripting languages have been a personal no-go zone.
My current thinking is that I should create a "utilities" Function-App and then launch a function when required via the portal function-test feature. Is there a better option?

I created a function app via the Azure Portal and a new function to invoke my utility code. Within the Azure Portal under the C# template options for a new function, there is "Manual" option described as follows "A C# function that is triggered manually via the portal "Run" button".
In the absence of extra official Microsoft documentation I assume this is an isolated function hosted within a function App with no external bindings such as a Storage Queue. This provides a solution to my question as I hope there is no alternative invokable public URL endpoint linked to such a manual function.

Related

Deploying an WebAPI project (including swagger) into Azure Function

I know that the Azure function supports HTTP trigger and we can write a function that can be exposed like an API. I'm looking for an option to host a complete C# WebAPI project (multiple Rest endpoints including swagger definition) into a single Azure function.
Is this feasible? and supported? I see this scenario is completely supported in AWS Lambda. Where we can deploy a whole WebAPI project into a single lambda. Here is the demo of
the same.
I have watched the provided Video and I observed the same functionality is also available in Azure Functions.
As Direct way is not available like publishing the Web API to the Functions but migration of Web API to Functions is possible if the Web API is authenticated with any option like Open API, etc and using the APIM Service we can manage all the operations in it.
And as per the Microsoft Update, Startup.csand program.cs is unified to the program.cs file. So, I have added the required swagger configuration code in the file program.cs and tested it, working successful locally.
Another approach is you can call the Web APIs from Azure Functions securely, here is one of my approaches along with few other ways to do it.
Refer to #VovaBilyachat alternative solution on publishing .NET Core Web API to Azure that provides the glimpse of using Containers instead Functions.

Editing Java Function Apps is not supported in the Azure portal error

So, when I am trying to create a function inside a function app it shows Editing Java Function Apps is not supported in the Azure portal.
The Add button is not working and only local development option is present.
How can I overcome this problem?
Currently, it seems that we cannot create Java Function on Azure portal, because creating Java Function requires Maven or Gardle, but Azure portal does not seem to contain them.
So we can only develop Java Function locally and then deploy them to the Azure portal.
If you want to get this feature, you can go to the Feedback page to post your thoughts, and the Azure development team may adopt your suggestions.
By the way, not only Java, only script programming languages can be added to Azure Portal. In other words, Azure Portal can only create functions that use languages that do not require compilation
You might say that C# can be created directly on Azure portal, but the c# function created in Azure Portal is actually the c# script.

Automate updates from Azure Function App to API Management

Given that Azure Functions can be imported to API Management as described here, how do we keep the API up to date when Azure Functions change? For example, if the Function signature changes or a function is added or removed. How can this process be automated, so once the Azure Functions change, the changes are reflected in the API?
Microsoft's API Management team has a proposed solution here, but it's not clear to me how this solution can be applied with Azure Function App as the backed-end for the API.
Yes, you need to make it as part of your release process. After publishing the new version of Azure Functions, you'll import the new specification into API Management.
https://marketplace.visualstudio.com/items?itemName=stephane-eyskens.apim
Once you import and publish an API in APIM it will not be updated automatically. So, even though the developers released a new build, the consumers would still consume the older version of the API published in APIM.
Try to use Azure DevOps pipelines for continuous delivery of APIs to Azure API Management Service.
Add a create/update task, which will create or update the API in APIM based on the Swagger file and also set different API policies. This task will also update the API in APIM in case the Dev guy will create new API methods or remove API methods.

Is it possible to stop/start an Azure ARM Virtual Machine from an Azure Function?

Runbooks can be used to stop/start classic and ARM Virtual Machines in Azure.
Is this also possible from an Azure Function?
Some good news to update this thread. You will be able to do that now in Azure Functions. The steps are documented here based on HTTP-triggered Functions.
Azure Function role like permissions to Stop Azure Virtual Machines
You may switch out the trigger type to fit your use-case.
See Ling's response above. We've addressed this now. :)
It's not currently possible to do this via the Azure PowerShell commandlets in Azure Functions. You can write against the Azure C# SDK or use the x-plat CLI (if you bring it yourself, as it isn't installed by default). You'll need to upload a cert or use a service account to perform those actions.
FYI - I'm on the Functions team and we're working on improving this story, in the near future. I'll update this answer once it's been made possible.
You can either use the Azure REST API from here -> Docs or make use of the SDK to do the operations.

Azure worker role automation

I created my custom Azure Worker Role. This code is ready. What I'm trying to do is to create instances of this Azure-Worker-Role in specific Azure data-center, at the requested time. For example, I'm want to send command to Azure to create 10 instances of my Custom-Azure-Worker in West-Europe data-center - now.
It's important to pass this command also a parameter that will be the input problem to be solved by my workers.
I pretty sure that this automation task must be covered by Azure automation. Is that true? Looking for more information\directions.
Thank you!
You can use Azure Management Libraries to create and deploy your cloud services from C# code. Just create application (eg ASP.NET MVC) to manage your cloud services by sending commands and deploy it also on Azure or even keep it locally.
See this article for more details http://www.bradygaster.com/post/getting-started-with-the-windows-azure-management-libraries
You'll want to leverage the service management API to spin up and tear down roles. It can be accessed any number of way, including directly via REST.
RE: providing a parameter to the worker role, one option is leveraging the cloud service configuration file that you provide with the cspkg. Define specifics for the role there.
Depending on the complexity or simplicity of your scenario, you may also get away with simply having a table in storage that you personally poke with desired configuration values and that the worker can read to retrieve.
The Azure Automation service should definitely be able to automate this task for you. Anything you can script via the Azure PowerShell module, can be imported as a runbook and called manually, via a third-party system, or on a schedule in Azure Automation.
Whether there is an existing runbook for the specific task you are looking to automate, I do not know. But Azure Automation has a gallery of community-contributed content for many common processes, so this may be available there.

Resources