azure_functions_en_powershell_7
This is an old revision of the document!
Table of Contents
Step-by-step checklist: Azure Functions en PowerShell 7 / uso general
1. Instalación de herramientas
- Instalar y verificar Azure CLI en PowerShell 7.
- Instalar
Azure Functions Core Tools v4:- Opción MSI (Windows): descargar desde la documentación oficial de Microsoft.
- Verificar instalación:
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.
- Conclusión típica: 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.pycon 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
authLevelaanonymouspara 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:- 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.1763992225.txt.gz · Last modified: 2025/11/24 13:50 by oso
