Private External Git on Azure Function App - azure

Is there any way to configure the deployment center of a function, as below, using the az cli?
I tried to use az functionapp deployment source config, but I didn't find any parameter to put the password and user.

According to the docs you have parameters available to provide the authentication information:
https://docs.azure.cn/en-us/cli/functionapp/deployment/source?view=azure-cli-latest#az-functionapp-deployment-source-config
[--private-repo-password]
[--private-repo-username]
However I don't get these as options when using the Azure CLI -h (not even in the latest version in cloud shell). Not sure if the auto-complete is just failing to parse them or they're not available at all.

Related

How do I add a custom domain with 'on other DNS' option to a static web app with Azure CLi

I would like to add a custom domain that is managed by AWS to my Azure Static Web App. Microsoft documentation shows how to add one if the DNS is managed by Azure itself. Sadly, I cannot find anything for my use case. To be more clear, the function I'd like to use with Azure command line is shown in this picture.
I have tried az staticwebapp hostname set --name FOO --hostname BAR.com which doesn't work.
I suppose you have already configured CNAME/TXT/ALIAS record with your DNS provider.
You may use --no-wait option to not wait for validation or use --validation-method "dns-txt-token" or "cname-delegation"
I would also suggest to verify your CNAME record, as often domain field must be filled with subdomain, not regular/naked domain.
Please also check if you are using the latest version of az cli.
You may check version using command az version
https://learn.microsoft.com/en-us/cli/azure/staticwebapp/hostname?view=azure-cli-latest#az-staticwebapp-hostname-set-examples

NodeJS for Azure CLI command: az resource show $resourceID

I'm trying to figure out if resources exist in Azure by using their resource ID. The Azure CLI command would be az resource show $resourceID. My application is in NodeJS.
Is there some equivalent in NodeJS I can use in my application? If not, is there another way to show a resource exists (information populates) or does not exist (null fields) in NodeJS?
Ultimately want to return true (exists) or false (does not exist).
To access Azure from your application, you can use their SDK. It uses similar terminology to Azure CLI. For your specific command, I believe checkExistenceById is what you are looking for.
Follow the installation instructions and learn the docs to see how to integrate the SDK into your app:
$ npm install azure-arm-resource

In Azure Functions, where do we put settings we want to put on Azure?

So just started playing with Azure Functions, I have a new project with some appsettings in the local.settings.json file.
So this works on my local, but obviously when I deploy to Azure Functions, local.settings.json file isn't used.
Where are we supposed to specify our settings for an Azure Function?
Is there a azure.settings.json file? Or some sort of way to deploy an settings file during the deployment?
If you want to add settings, you could use the way provided by Matt, and if you want to deploy the Function to Azure with the settings in the local.settings.json, there is another way to implement it.
Install the Azure Functions Core Tools on the local, publish the Function with -publish-local-settings -i and if you are using the version 2 the --publish-settings-only -o could only publish settings and skip the content.
The below pic is a sample, you could find it will prompt to overwrite value in azure if setting is different between azure and local.settings.json.
Further more information, you could refer to this tutorial: Publish to Azure.
Just like an Azure App Service, and Azure Function has an Application Settings tab where you can configure these through the Azure Portal. To access these you go to: Your function app > Overview > Configured Features> Configuration, you can then add the settings that you need under the Application Settings tab.
Alternatively, if you would prefer configuring these through a CLI then that option is also available. The main documentation is here.
Edit
For a solution as part of your CI/CD you have two options (examples will use Azure DevOps and perform the action in the CD step):
PowerShell Task. You could add a Powershell (or any type of script that will talk to the Azure CLI for functions) script as part of your CD step. This post goes through the process step by step, the bit you are probably interested in is under "Deploying with Azure DevOps Release Pipeline". Essentially it is building up a collection of your appsetting keys and their values, then a call to Set-AzureRmWebApp the and pass in the collection to the -AppSettings flag as per these docs
Azure CLI task. Same as above but you could use the Azure CLI task along with the Inline script option to call the az functionapp config appsettings set command docs here. The --settings flag takes:
Space-separated app settings in a format of =.
So
az functionapp config appsettings set --name MyFunctionApp --resource-group MyResourceGroup --settings "settings1Key=settings1Value settings2Key=settings2value"
The Azure Functions for .NET template for CI (Build) and Deploy a function app to Azure Functions template for CD (Release) inside Azure DevOps will come in handy.

Pass flags to docker in Azure aci

I have a container image (rancher/rancher:latest) that I need to pass "--acme-domain=" flag.
How can this be done in Azure Aci?
After a lot of trial and error I was able to do this using the command parameter in the Azure Resource Manager template. The gist of it was that I had to explicitly call the container entry point, e.g. "command":["./scripts/entry","--acme-domain=foo"]. I suppose you could do the same with the --command-line argument in the Azure CLI.
You can try to set an environment variable for your tag "--acme-domain=" in Azure ACI.
For more details, see Set environment variables in Azure ACI.

In Azure, how do I deploy functionapp code without using git?

I created a Resource Manager template which has the Resources to run a function app basically using the default template for this purpose and I can manually copy files to my File Storage under sites\wwwroot and when I curl the functionapp it works.
But what I'm wondering is, what is the right way to deploy a bunch of files to update the actual functionapp, but not using git. I can see some examples of how to use git but my problem is that I want to have all my functions in a single repo not a bunch of smaller repos (I want a monorepo).
In Azure you just upload your code in a .gz file to S3 then when creating the lambda you give it a path to the zip. And then later there is a simple API that you can call to push up a new zip and presto.
What is the equivalent API in azure to just give it a zip and have it unpack the files in the right directory?
EDIT:
I managed to figure it out finally, the top answer was essentially right but there were a few extra steps I had to figure out so I'll put those here.
The specific doc on curl is here. My issue thread with the team is here.
The actual curl call I used is this:
$ curl -XPUT --data-binary #index.js.zip "https://abc:xyz#ugh.scm.azurewebsites.net/api/zip/site/wwwroot/hello"
Notes on this:
You must use --data-binary, -d results in a bad payload
To create the zip in bash I used: $ zip index.js.zip index.js
abc:xyz is the deployment username and password
The right path to send is site/wwwroot/hello where hello is the name of the function.
You can set the username and password in the azure portal UI (documented here) but you can also set it with the azure-cli like so:
$ az login
$ az webapp deployment user set --user-name abc --password xyz
And that was the trick, once you've setup the deployment credentials you can use them in basic auth to call the kudu api.
Using Rest API to deploy Function App is also allowed in Azure. We could use the following Rest API to do that. We could get more detail info from Kudu REST API. We could get the ftp use and password from publish file, about how to publish file, please refer to another SO thread.
PUT https://{user}:{password}#{FunctionAppname}.scm.azurewebsites.net/api/zip/{path} # example path:site/wwwroot

Resources