Following Microsoft Quick Start for Function App with Go (https://learn.microsoft.com/en-us/azure/azure-functions/create-first-function-vs-code-other?tabs=go%2Cwindows)
I was able to successfully run the code locally on my Windows computer. I continued to follow the steps to deploy the Function App to Azure portal and when try to run the Function App at the /api/HttpExample endpoint. It would fail to execute even though it runs fine locally.
Programming language used : Go 1.17.7
Links to source: https://learn.microsoft.com/en-us/azure/azure-functions/create-first-function-vs-code-other?tabs=go%2Cwindows
Bindings used
I had the same problem (working locally, wouldn't load when deployed), but I am running Linux locally. The error message I got was:
An attempt was made to access a socket in a way forbidden by its access permissions.
I was creating the Azure Function App through the VS Code Azure extension, and the default OS when creating a Function App is Windows:
The clue was to select the Advanced option and select OS->Linux. With the AZ CLI you need to add the option --os-type Linux, e.g.:
az functionapp create --os-type Linux --resource-group hellogorgplinux --consumption-plan-location eastus --runtime node --runtime-version 10 --functions-version 3 --name hellogoapplinux --storage-account hellogostglinux
Related
I have an Azure release pipeline that uses an Azure Web App for Containers task to deploy a docker image on an Azure App Service.
The image is specified in the form of some_image:$(Build.BuildId). The pipeline works as intended and successfully updates the App Service with the latest built of the image.
I want from an other release pipeline to execute a docker run command using that image. I've noticed that version 1 of the Docker task allows me to execute such a docker run command on a docker image (no idea why run is missing from version 2), but how can I specify the docker image? How can I get which image is the currently deployed on that App Service?
You can either use PowerShell or Shell script in the YAML pipeline. Since you already know the container registry and the image name, just use the below command to get the latest version
az acr repository show-tags -n MyRegistry --repository MyRepository --top 1 --orderby time_desc --detail
https://learn.microsoft.com/en-us/cli/azure/acr/repository?view=azure-cli-latest#az_acr_repository_show_tags
Might be too late now, but what you want to do is to get the value of LinuxFXVersion (if you're running docker on Linux) property from Azure Resource Explorer.
Using a combination of Azure PowerShell and CLI, you can have these commands to retrieve the current image running on your web app:
$webAppProperties = (az webapp config show --subscription "<subscription-id>" --resource-group "<resource-group-name>" -n "<webapp-name>") | ConvertFrom-Json
$webAppProperties.linuxFXVersion
Assuming you have the right permissions to your subscription from Azure Pipelines, you should be able to use this information for the next steps.
I am trying to download and install an exe during the provisioning of a Windows VM in Azure cloud. I do not want to use Custom Script Extension but instead I want to use "Custom Data". I cannot find any solid examples on Azure documentation.
In AWS, I found enough resources and I could develop the below PowerShell script and add it to the User Data but that doesn't work on Azure, I tried different variations but with no luck. Has anyone done that before? Is there any clear documentation on that? I read Azure uses Cloud-init but again, no clear examples on how to do that with Cloud-init for a Windows machine, all examples are for Linux.
<powershell>
start-transcript
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest 'https://www.domain-name.com/filename.exe' -OutFile C:\filename.exe
C:\filename.exe --quiet
</powershell>
Any help would be appreciated.
You can inject data into a Windows virtual machine on Azure, but you can't execute it using custom data or cloud init unfrotunately. Execution of the custom data using cloud init is only supported in Ubuntu images.
Source: https://azure.microsoft.com/es-es/blog/custom-data-and-cloud-init-on-windows-azure/
To achieve an execution of a script post provisioning, it depends on how you're provisioning the VM.
In ARM templates you can use custom script extensions: https://learn.microsoft.com/en-us/azure/virtual-machines/extensions/custom-script-windows
Using Azure CLI you can execute a script using az vm run-command like this:
az vm run-command invoke --command-id RunPowerShellScript --name win-vm -g my-resource-group \
--scripts 'param([string]$arg1)' \
'Write-Host Hello' \
--parameters 'arg1=kemety'
Sourced from here: https://learn.microsoft.com/en-us/cli/azure/vm/run-command?view=azure-cli-latest
We are migrating from Jenkins to Azure and in our deployment we used Powershell scripts, for our initial move we are trying not to adjust our Powershell scripts and just change the bare minimum to get them working.
On the running of command:
az webapp deployment source config-zip --name Name --resource-group RG --src Path/To/Zip.zip
When we used this command before we got the warning:
WARNING: Getting scm site credentials for zip deployment
We now get this warning as an Error:
[error]WARNING: Getting scm site credentials for zip deployment
I have adjust the settings to try continue past errors but it falls out anyway. Anyone know how to fix this?
I am using version 2.0.60 of Azure-cli. I have tried with az webapp deployment source config-zip command, I also got the warning. But the webapp was deployed successfully.
You can also deploy the zip file via browser.
1.In the browser, navigate to https://<app_name>.scm.azurewebsites.net/ZipDeployUI.
2.Drag the zip file to the file explorer area on the web page
Is it possible to exec a command in a windows container related to a webapp based on a container? I'm not able to find the right name to use on the cli command az app exec. In fact az container list returns me an empty list. However the container exits cause the web app is running. Where can I find the right name to use with az app exec command? I also checked with the name of only one slot in the webapp without success.
The error az app exec returns is:
The Resource 'Microsoft.ContainerInstance/containerGroups/theNameIPRovide' under resource group 'thegroupNameIProvide' was not found.
Unfortunately, there is no Azure CLI command for Web app for Container to exec the command inside the container. But you can use other ways, for example, the API.
There is no CLI command like az app exec. And az container is for ACI, not for the Web App. You can get all CLI command for Web App in az webapp.
Or you can deploy your application in Azure Container Instance, it also can run windows container for you. So that you can use the CLI command az container exec to execute the command inside your application.
Could you have a look at this https://learn.microsoft.com/en-us/cli/azure/container?view=azure-cli-latest#az-container-exec, Couldnt comment, so had to post it in an answer
I am unable to install the VSTS Agent Azure VM extension on an Azure VM. I tried both the Install extension blade in the Azure portal and the Powershell option. When I try from the portal it just gets stuck at transitioning. If I run the Powershell script it gets stuck trying to connect to server.
I was able to install it on another server without any issues. The 2 servers are part of a web farm so they are exact images.
I am following the steps detailed at this url https://learn.microsoft.com/en-us/vsts/build-release/concepts/definitions/release/deployment-groups/howto-provision-deployment-group-agents?view=vsts .
I am trying to deploy from VSTS to an Azure VM.
This is the screen when I try to run the powershell script.
Run the config file directly (from C:/vstsagent folder) in cmdline and try again with dev.azure.com/{organisation name} url.