User Tools

Site Tools


azure_functions_en_powershell_7

This is an old revision of the document!


Step-by-step checklist: Azure Functions en PowerShell 7 / uso general

1. Instalación de herramientas

func –version

2. Verificación del App Service Plan

  • Listar apps en un resource group:

az webapp list –resource-group “<nombre-del-rg>”

  • Si al crear una Function App aparece un error de compatibilidad de runtime con Windows, suele indicar que el App Service Plan está configurado como Windows. Para runtimes como Python, se requiere Linux.

3. Creación de Function App (Linux)

  • Crear Function App con plan de consumo, runtime Python 3.11:
az functionapp create `
  --resource-group <nombre-del-rg> `
  --consumption-plan-location <región> `
  --runtime python `
  --runtime-version 3.11 `
  --functions-version 4 `
  --name <nombre-de-la-functionapp> `
  --storage-account <nombre-storage> `
  --os-type Linux
  • Resultado esperado: Function App creada y vacía, lista para desplegar.

4. Inicialización del proyecto local

  • Crear carpeta de trabajo y ejecutar:

func init . –python

  • Crear función HTTP trigger con acceso anónimo:

func new –name ItWorksFunc –template “HTTP trigger” –authlevel anonymous

  • En Functions v4 para Python se genera function_app.py con decorators.

5. Publicación y pruebas

  • Publicar el proyecto en la Function App:
func azure functionapp publish <nombre-de-la-functionapp>
  • Probar endpoint en navegador o curl:
https://<nombre-de-la-functionapp>.azurewebsites.net/api/ItWorksFunc
  • Ajustar authLevel a anonymous para evitar respuestas 401.
  • Respuesta típica de prueba:
"it works! running at Azure Functions"

6. Extensión a múltiples endpoints

  • Definir endpoints adicionales en function_app.py:
    1. Ejemplo: /backups, /updates, /inventory, /status
  • Cada endpoint puede recibir JSON vía POST, validar datos y guardar en Storage/SQL/Logs.
  • Prueba con curl:
curl -X POST https://<functionapp>.azurewebsites.net/api/backups \
     -H "Content-Type: application/json" \
     -d '{"server":"srv01","status":"ok"}'
azure_functions_en_powershell_7.1763992926.txt.gz · Last modified: 2025/11/24 14:02 by oso