:::: MENU ::::

Python Azure Function application error – underlying container unavailable

Recently I’ve been having some issues with Python Azure Functions that after deployment the underlying container was down. Redeployment, restart doesn’t help and still you can see this screen.

🙁 Application Error
If you are the application administrator, you can access the diagnostic resources.

After some investigation I’ve found out in Azure Function “Availability and Performance” diagnostics that there is a following error:

ERROR: unhandled error in functions worker: Descriptors cannot not be created directly.

After further checks it looks like it’s related to the profobuf library. Even though I’m not using it directly it looks like some of the libraries is using this library.

Solution

Add proper version to your requirements.txt file:

protobuf==3.20.*

and redeploy the app. This solution solved my problem.


Email Address Regular Expression That 99.99% Works

General Email Regex (RFC 5322 Official Standard)

(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])

Railroad Diagram of Above Regex

Source: https://emailregex.com/

Python

r"(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)"

Javascript

/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/

HTML5

<input type="email" placeholder="Enter your email" />
/^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/

Swift (Regex only)

[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}

Swift (Regex used in a function)

func validateEmail(candidate: String) -> Bool {
 let emailRegex = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}"
 return NSPredicate(format: "SELF MATCHES %@", emailRegex).evaluateWithObject(candidate)
}

PHP

/^(?!(?:(?:\x22?\x5C[\x00-\x7E]\x22?)|(?:\x22?[^\x5C\x22]\x22?)){255,})(?!(?:(?:\x22?\x5C[\x00-\x7E]\x22?)|(?:\x22?[^\x5C\x22]\x22?)){65,}@)(?:(?:[\x21\x23-\x27\x2A\x2B\x2D\x2F-\x39\x3D\x3F\x5E-\x7E]+)|(?:\x22(?:[\x01-\x08\x0B\x0C\x0E-\x1F\x21\x23-\x5B\x5D-\x7F]|(?:\x5C[\x00-\x7F]))*\x22))(?:\.(?:(?:[\x21\x23-\x27\x2A\x2B\x2D\x2F-\x39\x3D\x3F\x5E-\x7E]+)|(?:\x22(?:[\x01-\x08\x0B\x0C\x0E-\x1F\x21\x23-\x5B\x5D-\x7F]|(?:\x5C[\x00-\x7F]))*\x22)))*@(?:(?:(?!.*[^.]{64,})(?:(?:(?:xn--)?[a-z0-9]+(?:-[a-z0-9]+)*\.){1,126}){1,}(?:(?:[a-z][a-z0-9]*)|(?:(?:xn--)[a-z0-9]+))(?:-[a-z0-9]+)*)|(?:\[(?:(?:IPv6:(?:(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){7})|(?:(?!(?:.*[a-f0-9][:\]]){7,})(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,5})?::(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,5})?)))|(?:(?:IPv6:(?:(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){5}:)|(?:(?!(?:.*[a-f0-9]:){5,})(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,3})?::(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,3}:)?)))?(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9]{2})|(?:[1-9]?[0-9]))(?:\.(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9]{2})|(?:[1-9]?[0-9]))){3}))\]))$/iD

Perl / Ruby

(?:(?:\r\n)?[ \t])*(?:(?:(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t]
 )+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:
 \r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(
 ?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[
 \t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\0
 31]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\
 ](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+
 (?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:
 (?:\r\n)?[ \t])*))*|(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z
 |(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)
 ?[ \t])*)*\<(?:(?:\r\n)?[ \t])*(?:@(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\
 r\n)?[ \t])+|\Z|(?=[\["()<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-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>
 @,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*(?:,@(?:(?:\r\n)?[
 \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,
 ;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t]
 )*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\
 ".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*)*:(?:(?:\r\n)?[ \t])*)?
 (?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".
 \[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(?:
 \r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\[
 "()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])
 *))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])
 +|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\
 .(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z
 |(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*\>(?:(
 ?:\r\n)?[ \t])*))*)?;\s*)

Perl 5.10 or newer

/(?(DEFINE)(?<address>(?&mailbox) | (?&group)) (? (?&name_addr) | (?&addr_spec)) (? (?&display_name)? (?&angle_addr)) (? (?&CFWS)? < (?&addr_spec) > (?&CFWS)?) (? (?&display_name) : (?:(?&mailbox_list) | (?&CFWS))? ; (?&CFWS)?) (? (?&phrase)) (? (?&mailbox) (?: , (?&mailbox))*) (? (?&local_part) \@ (?&domain)) (? (?&dot_atom) | (?&quoted_string)) (? (?&dot_atom) | (?&domain_literal)) (? (?&CFWS)? \[ (?: (?&FWS)? (?&dcontent))* (?&FWS)? \] (?&CFWS)?) (? (?&dtext) | (?&quoted_pair)) (? (?&NO_WS_CTL) | [\x21-\x5a\x5e-\x7e]) (? (?&ALPHA) | (?&DIGIT) | [!#\$%&'*+-/=?^_`{|}~]) (? (?&CFWS)? (?&atext)+ (?&CFWS)?) (? (?&CFWS)? (?&dot_atom_text) (?&CFWS)?) (? (?&atext)+ (?: \. (?&atext)+)*) (? [\x01-\x09\x0b\x0c\x0e-\x7f]) (? \\ (?&text)) (? (?&NO_WS_CTL) | [\x21\x23-\x5b\x5d-\x7e]) (? (?&qtext) | (?&quoted_pair)) (? (?&CFWS)? (?&DQUOTE) (?:(?&FWS)? (?&qcontent))* (?&FWS)? (?&DQUOTE) (?&CFWS)?) (? (?&atom) | (?&quoted_string)) (? (?&word)+) # Folding white space (? (?: (?&WSP)* (?&CRLF))? (?&WSP)+) (? (?&NO_WS_CTL) | [\x21-\x27\x2a-\x5b\x5d-\x7e]) (? (?&ctext) | (?&quoted_pair) | (?&comment)) (? \( (?: (?&FWS)? (?&ccontent))* (?&FWS)? \) ) (? (?: (?&FWS)? (?&comment))* (?: (?:(?&FWS)? (?&comment)) | (?&FWS))) # No whitespace control (? [\x01-\x08\x0b\x0c\x0e-\x1f\x7f]) (? [A-Za-z]) (? [0-9]) (? \x0d \x0a) (? ") (? [\x20\x09]) ) (?&address)/x</address>

Java

(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])

Ruby (simple version)

/\A([\w+\-].?)+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i

.NET (general pattern match)

^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$

C#

^(?(")(".+?(?<!\\)"@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-\w]*[0-9a-z]*\.)+[a-z0-9][\-a-z0-9]{0,22}[a-z0-9]))$

VB.NET

Function isEmail(ByVal email as string) as boolean
    Static emailRegex As New Regex("^[_a-z0-9-]+(.[a-z0-9-]+)@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,4})$")

    return emailRegex.IsMatch(email)
End Function

Find All Email Addresses in a File using Grep

$ grep -E -o "\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}\b" filename.txt

SQL Server Email Validation

 select email 
 from table_name where 
 patindex ('%[ &'',":;!+=\/()<>]%', email) > 0 -- Invalid characters
 or patindex ('[@.-_]%', email) > 0 -- Valid but cannot be starting character
 or patindex ('%[@.-_]', email) > 0 -- Valid but cannot be ending character
 or email not like '%@%.%' -- Must contain at least one @ and one .
 or email like '%..%' -- Cannot have two periods in a row
 or email like '%@%@%' -- Cannot have two @ anywhere
 or email like '%.@%' or email like '%@.%' -- Cannot have @ and . next to each other
 or email like '%.cm' or email like '%.co' -- Camaroon or Colombia? Typos. 
 or email like '%.or' or email like '%.ne' -- Missing last letter

Oracle PL/SQL Email Regex

SELECT email 
FROM table_name
WHERE REGEXP_LIKE (email, '[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}');

MySQL

SELECT * FROM `users` WHERE `email` NOT REGEXP '^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$';

Disclaimer: this is a copy of the page emailregex.com which unfortunately became unavailable, so I’ve decided to restore it’s content on my website as it’s very useful!


Azure Functions on Mac M1 with PyEnv

Saved me several times. Great and easy to follow approach by anthonysomerset.

When using PyEnv just change the location from which you copy the file (copy the lib step).

# Install Python
brew install python@3.9

# install latest azure-function-core-tools from brew
brew install azure-functions-core-tools@4 

# Install grpcio inside python3.9
pip3.9 install grpcio

# copy the lib
cp /opt/homebrew/lib/python3.9/site-packages/grpc/_cython/cygrpc.cpython-39-darwin.so /opt/homebrew/Cellar/azure-functions-core-tools@4/4.0.4915/workers/python/3.9/OSX/X64/grpc/_cython/cygrpc.cpython-39-darwin.so

# symlink X64 to Arm64
cd /opt/homebrew/Cellar/azure-functions-core-tools@4/4.0.4915/workers/python/3.9/OSX/
ln -s X64 Arm64

#edit the worker config to reference arm64
cd /opt/homebrew/Cellar/azure-functions-core-tools@4/4.0.4915/workers/python
#use your text editor of choice e.g. nano
nano worker.config.json
# update supportedArchitectures like so
"supportedArchitectures":["X64", "X86","ARM64"],
# save and exit

# in your function directory setup a python 3.9 venv
cd <path to azure functions code>
python3.9 -m venv .venv
source .venv/bin/activate

# start func
func start

Source: GitHub


Azure DevOps / NuGet Restore – intermittent CredentialProvider.Microsoft fails

##[error]The nuget command failed with exit code(1) and error(Problem starting the plugin 'C:\vsts-agents\smh-agent-3\_work\_tasks\NuGetCommand_333b11bd-d341-40d9-afcf-b32d5ce6f23b\2.211.0\CredentialProviderV2\plugins\netfx\CredentialProvider.Microsoft\CredentialProvider.Microsoft.exe'. Plugin 'CredentialProvider.Microsoft' failed within 6.581 seconds with exit code -1.

This annoying error was intermittent and happened mostly when several builds were running.

I’m using two steps related to NuGet:
NuGet tool installer v1
NuGet v2 – configured for restoring packages for the project

I’ve discovered this thread on Visual Studio Developer Community that suggest that it may be an issue with default NuGet timeout, which is 5 seconds.

The suggestion is to increase the default timeout, which works for me.

I’ve set within build variables two new variables and so far it works better – no more CredentialProvider.Microsoft error.

NUGET_PLUGIN_HANDSHAKE_TIMEOUT_IN_SECONDS=30
NUGET_PLUGIN_REQUEST_TIMEOUT_IN_SECONDS=30

How to change tenant in Microsoft Graph Explorer

If you have multiple Active Directory tenants you work with and you’d like to use Microsoft Graph Explorer to interact with Microsoft Graph API you often have a need to switch between tenants.

Unfortunately, as of now, Microsoft Graph Explorer does not support switching tenant in their standard view. There is a workaround though!

You can pass tenant name in the URL, as follows:

https://developer.microsoft.com/en-us/graph/graph-explorer?tenant=YOUR_TENANT.onmicrosoft.com

Important!

If you are already signed in with your main tenant, you will have to switch account – click on your profile and then Sign in with a different account. If you have account on the other tenant you should be able to switch account. After doing so, the information about the tenant (next to you profile) should be updated!

Source


How to update Azure DevOps Service Principal connection once expired

When you use Azure DevOps to deploy your projects you can connect it to Azure via different methods. The most convenient type of service connection is `Azure Resource Manager using service principal authentication`.

This type of connection creates application in your Azure Active Directory which is used as a Service Principal. Then for this application secret is generated, so Azure DevOps can connect to Azure. This secret token is expiring from time to time. The default time to live is 2 years but it may vary.

Once the secret is expired you will get this type of error when trying to deploy your code to Azure:

##[error]Error: Failed to get resource ID for resource type 'Microsoft.Web/Sites' and resource name 'XXX'. Error: Could not fetch access token for Azure. Verify if the Service Principal used is valid and not expired. For more information refer https://aka.ms/azureappservicedeploytsg
Error during deployment once secret for Service Principal expired.
Continue Reading

Multiple PHP versions on MAC via Homebrew

Great post about having multiple PHP version in your console: https://getgrav.org/blog/macos-monterey-apache-multiple-php-versions.

Few snippets from the post:

brew tap shivammathur/php
brew install shivammathur/php/php@7.0
brew install shivammathur/php/php@7.1
brew install shivammathur/php/php@7.2
brew install shivammathur/php/php@7.3
brew install shivammathur/php/php@7.4
brew install shivammathur/php/php@8.0
brew install shivammathur/php/php@8.1
brew install shivammathur/php/php@8.2
brew unlink php && brew link --overwrite --force php@7.3


Setup Grafana email notification via SendGrid SMTP (also for Bitnami Grafana)

Setup API Key on SendGrid

  1. Go to your SendGrid account and go to API Keys section.
  2. Add new API Key with, at least, Mail Send permission.
  3. Copy generated API Key. Your key should start with SG.

Grafana setup

  1. You have to edit Grafana configuration. Refer to Grafana Configuration documentation on where to find your config file. For Bitnami Grafana distribution you can find it here: /opt/bitnami/grafana/conf/grafana.ini
  2. Look for [smtp] section and either update existing one or add new one
[smtp]
enabled = true
host = smtp.sendgrid.net:587
user = apikey
password = YOUR_SENDGRID_API_KEY
skip_verify = false
from_address = admin@grafana.localhost
from_name = Grafana

3. Restart Grafana: official documentation, Bitnami documentation.

Testing

  1. Go to Alert notification channels (/alerting/notifications)
  2. Create new channel with type email.
  3. Add email address
  4. Hit Test
  5. You should receive test notification sent by Grafana through SendGrid SMTP sevice!

Few remarks

enabled = true – by default it’s false and then SMTP is disabled.

smtp.sendgrid.net:587 – you can try different ports but this one is recommended by SendGrid here Integrating with the SMTP API.

user – you have to provide apikey as user, otherwise you will end up with 550 Unauthenticated senders not allowed.

skip_verify – in other SMTP servers you may have to set this to true, yet for SendGrid it will cause problems as described in Notification channel Email cannot integrate with Sendgrid.

from_adress – looks like you can put anything you want but I would recommend to put verified email address you have in SendGrid – check the Sender Authentication section.

Links

Grafana configuration reference

550 Unauthenticated senders not allowed error code description.

Integrating with the SMTP API


Azure Log Analytics / Application Insights – search everywhere

If you have Azure Log Analytics or Application Insights, where you have different data sources, like exceptions, requests, traces, customEvents, you may want to search for some certain phrase everywhere, because you don’t know in which data source you should check or in which column.

There is quite handy way of doing that – search in query.

Quick example:

search in (exceptions, requests, traces, customEvents) "ManagedIdentityCredential"

And details in documentation.


Pages:123456