{"id":95225,"date":"2023-01-03T22:04:06","date_gmt":"2023-01-03T22:04:06","guid":{"rendered":"https:\/\/www.red-gate.com\/simple-talk\/?p=95225"},"modified":"2023-01-03T22:04:06","modified_gmt":"2023-01-03T22:04:06","slug":"azure-function-and-user-assigned-managed-identities","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/cloud\/azure\/azure-function-and-user-assigned-managed-identities\/","title":{"rendered":"Azure Function and User Assigned Managed Identities"},"content":{"rendered":"<p>Let&#8217;s talk about authentication between <strong>Azure Functions<\/strong> and resources used by <strong>Azure Functions<\/strong> and conclude with many poorly documented secrets about how to use <strong>User Assigned Managed Identity.\u00a0<\/strong>When we build Azure functions, they usually need to authenticate against other Azure resources: <strong>Azure SQL Database<\/strong>, <strong>Storage Accounts<\/strong>, <strong>Service Bus<\/strong> and many more.<\/p>\n<p>Each of these services have an authentication that we can call <em>&#8220;Meh!&#8221;:<\/em> <strong>Azure SQL<\/strong> has <strong>SQL Standard Logins<\/strong>, storage accounts have <strong>SAS <\/strong>tokens, service bus, shared access keys and so on. These are not the safest methods possible. If the key leaks, you will have a security problem because anyone with the key will be able to access the resource.<\/p>\n<p>There are multiple solutions for this problem, some of them would pass through <strong>Key Vault, <\/strong>used to store secrets, keys and passwords. But let&#8217;s go directly to the best one: Remove the usage of keys at all.\u00a0<\/p>\n<p><em>How the Azure Function can authenticate against other services without using any key?<\/em><\/p>\n<p>We can assign an identity to the Azure Function and use this identity to authenticate on other resources. You can think about the identity as a special kind of Azure AD user. As with any other user, it can receive permissions in Azure resources, allowing your function to access the resources<\/p>\n<p>Instead of using a shared key in your system or configuration files, using an identity leaves it up to Azure to manage the access from the function to other resources. There will be no secret access key which could be exposed in your system.<\/p>\n<h2>The two kinds of identity<\/h2>\n<p>The identity we set to a Function App (or other Azure Resource) is called a <strong>Managed Identity<\/strong>. There are two kinds of <strong>Managed Identity<\/strong>: The <strong>System Assigned Managed Identity<\/strong> and the <strong>User Assigned Managed Identity<\/strong>. <\/p>\n<p>First of all, it\u2019s important to understand that for both types, we are responsible to set the identity permissions, which is explained later.<\/p>\n<p>The <strong>System Assigned Managed Identity<\/strong> is the perfect example of the <strong>KISS<\/strong> principle (Keep It Simple): You just turn it on in an Azure Function. The identity is created with the same name as your function app. You can give permissions to this identity and that&#8217;s it, your function will be able to access the resources you need.<\/p>\n<p>When you delete the function app, the identity with all its permissions is deleted as well.<\/p>\n<p>The <strong>User Assigned Managed Identity<\/strong> is a bit more complex. Why would you need a more complex solution?<\/p>\n<p>If you have multiple Function Apps and all of them requires access to the same resources, using System Assigned Managed Identities becomes a problem. The management of permissions for each individual function identity is at least annoying, and it&#8217;s also prone to mistakes.<\/p>\n<p>The solution is to create a custom identity and assign the same identity to all Function Apps which requires the same set of permissions. In this way, you manage the permissions on a single identity, instead of many.<\/p>\n<p><strong>This is the rule:<\/strong> If the permissions are needed by a single function, use a System Assigned Managed Identity and the identity lifecycle will be managed together the function lifecycle. If many functions need the same set of permissions, use a User Assigned Managed Identity and you will need to manage the permissions only for a single identity.<\/p>\n<table style=\"border-collapse: collapse; width: 100%;\">\n<tbody>\n<tr>\n<td style=\"width: 33.3333%;\">\u00a0<\/td>\n<td style=\"width: 46.069%;\">\n<p><strong>System Assigned Managed Identity<\/strong><\/p>\n<\/td>\n<td style=\"width: 43.7931%;\">\n<p><strong>User Assigned Managed Identity<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 33.3333%;\">\n<p><strong>Usage<\/strong><\/p>\n<\/td>\n<td style=\"width: 46.069%;\">\n<p>Used by one single function<\/p>\n<\/td>\n<td style=\"width: 43.7931%;\">\n<p>Can be assigned to multiple Function Apps and other cloud apps<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 33.3333%;\">\n<p><strong>Lifecycle<\/strong><\/p>\n<\/td>\n<td style=\"width: 46.069%;\">\n<p>Is created when turned on in the Function App and dropped together the Function App<\/p>\n<\/td>\n<td style=\"width: 43.7931%;\">\n<p>Created and dropped independently of the Function App. Someone needs to manage the identity<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 33.3333%;\">\n<p><strong>How does it work<\/strong><\/p>\n<\/td>\n<td style=\"width: 46.069%;\">\n<p>It simply works<\/p>\n<\/td>\n<td style=\"width: 43.7931%;\">\n<p>It may require variables or properties to work, but these will not contain any sensitive information<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Enabling System Assigned Managed Identity<\/h2>\n<p>As I mentioned before, these are very simple. You can just access the Identity tab and turn the identity on. The name of the identity is the name of the function app.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"834\" height=\"417\" class=\"wp-image-95226\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2023\/01\/word-image.png\" \/><\/p>\n<hr \/>\n<h2>Enabling User Assigned Managed Identity<\/h2>\n<p>User Assigned Manage Identities have an independent life cycle. This means you need to create them directly from the Marketplace. To do this, locate the User Assigned Managed Identity in the marketplace resources and create it as illustrated on the following images:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"651\" height=\"241\" class=\"wp-image-95227\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2023\/01\/word-image-1.png\" \/><\/p>\n<hr \/>\n<hr \/>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"654\" height=\"298\" class=\"wp-image-95228\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2023\/01\/word-image-2.png\" \/><\/p>\n<p>The creation itself is a generally simple matter of choosing the resource group and name of the identity. Consider the company standards for naming and resource group distribution. Some questions you should ask:<\/p>\n<ul>\n<li>Are you going to share this identity with objects in different resource groups?<\/li>\n<li>Are you going to share this identity across different projects?<\/li>\n<li>Are you going to share this identity across different environments (dev\/uat\/production)?<\/li>\n<\/ul>\n<p>Of course, the more granular the identity permissions are, the better, but you are using this object because you want to share the same set of permissions across different App objects to begin with.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"783\" height=\"449\" class=\"wp-image-95229\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2023\/01\/word-image-3.png\" \/><\/p>\n<hr \/>\n<p>After creating the identity, you will be able to see it in the chosen resource group.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"540\" height=\"156\" class=\"wp-image-95230\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2023\/01\/word-image-4.png\" \/><\/p>\n<hr \/>\n<p>The next step is to assign the identity to the function app. The Identity tab has the option to include a User Assigned Managed Identity to the app. The following images illustrate the steps used for this.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"502\" height=\"268\" class=\"wp-image-95231\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2023\/01\/word-image-5.png\" \/><\/p>\n<hr \/>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"429\" height=\"603\" class=\"wp-image-95232\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2023\/01\/word-image-6.png\" \/><\/p>\n<hr \/>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"695\" height=\"251\" class=\"wp-image-95233\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2023\/01\/word-image-7.png\" \/><\/p>\n<p>As you may notice on the images, it\u2019s possible to assign multiple identities to the same Function App. We can assign one System Assigned Managed Identity as well as multiple User Assigned Managed Identity. The usage of multiple identities is usually managed by code. In some situations, can be done by configurations as well.<\/p>\n<p>The scenario with multiple identities, where maybe your security requires different identities to access each resource, goes beyond the subject of this blog.<\/p>\n<h2>Assigning permissions to the Identity<\/h2>\n<p>In this section, I will discuss the details of how the identity gets access to resources that you choose.<\/p>\n<h3>RBAC Permissions<\/h3>\n<p><strong>Role Based Access Control<\/strong> is the usual access control used for most Azure services. In our examples, I will illustrate <strong>Service Bus<\/strong> and <strong>Storage Accounts<\/strong> usage of RBAC permissions. Let\u2019s consider our function will need access to a storage account and a service bus namespace. The identity given to the function needs to receive RBAC permission on both.<\/p>\n<p>The method to set RBAC permissions on the services is always similar.<\/p>\n<ol start=\"1\">\n<li>Click <em>Access Control (IAM)<\/em><\/li>\n<\/ol>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"995\" height=\"357\" class=\"wp-image-95234\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2023\/01\/word-image-8.png\" \/><\/p>\n<hr \/>\n<ol start=\"2\">\n<li>Click <em>Role Assignments<\/em> tab<\/li>\n<\/ol>\n<p>\u00a0 \u00a0 \u00a0 <img loading=\"lazy\" decoding=\"async\" width=\"883\" height=\"546\" class=\"wp-image-95235\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2023\/01\/word-image-9.png\" \/><\/p>\n<hr \/>\n<ol start=\"3\">\n<li>Click + <em>Add<\/em> button and choose: <em>Add Role Assignment <\/em>menu item<\/li>\n<\/ol>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"390\" height=\"122\" class=\"wp-image-95236\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2023\/01\/word-image-10.png\" \/><\/p>\n<hr \/>\n<ol start=\"4\">\n<li>Select the role you would like to assign and click <em>Next <\/em>button<\/li>\n<\/ol>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"917\" height=\"521\" class=\"wp-image-95237\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2023\/01\/word-image-11.png\" \/><\/p>\n<hr \/>\n<ol start=\"5\">\n<li>Select <em>Managed Identity<\/em><\/li>\n<\/ol>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"456\" height=\"321\" class=\"wp-image-95238\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2023\/01\/word-image-12.png\" \/><\/p>\n<hr \/>\n<p>There isn\u2019t much different between selecting <em>Managed Identity<\/em> or <em>User, Group or Service Principal<\/em>. You can find the identity in both ways. The <em>Managed Identity<\/em> option only makes it easier to locate Managed Identities<\/p>\n<ol start=\"6\">\n<li>Click <em>Select Members<\/em> link, then on the <em>Select Managed Identities<\/em> tab, open the <em>Managed Identity<\/em> drop down<\/li>\n<\/ol>\n<p>This drop down summarizes to you all available Managed Identities in the subscription. The System Assigned Managed Identities are related to azure objects, while User Assigned Managed Identities are independent.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"565\" height=\"663\" class=\"wp-image-95239\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2023\/01\/word-image-13.png\" \/><\/p>\n<hr \/>\n<ol start=\"7\">\n<li>Select the identity you created<\/li>\n<\/ol>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"565\" height=\"341\" class=\"wp-image-95240\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2023\/01\/word-image-14.png\" \/><\/p>\n<hr \/>\n<ol start=\"8\">\n<li>Click the <em>Review + Assign<\/em> button<\/li>\n<\/ol>\n<h3>Service Bus<\/h3>\n<p>Service Bus has three main roles you would like to assign: <em>Service Bus Data Owner<\/em>, <em>Service Bus Data Receiver<\/em> and <em>Service Bus Data Sender<\/em>. Probably you will assign the last two to your functions, depending if they send data to service bus or receive data from service bus.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"762\" height=\"331\" class=\"wp-image-95241\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2023\/01\/word-image-15.png\" \/><\/p>\n<hr \/>\n<p>You can assign permissions on the service bus level, the topic level or queue level. This brings an interesting decision to be made: you can use a single identity with access to multiple queues and topics or use multiple identities, one for each set of resources a function need.<\/p>\n<p>The latter is safer, of course. The first option, on the other hand, can lead to situations where a function has access to queues and topics it doesn&#8217;t need to access.<\/p>\n<p>Here come the corporate procedures again: Does your company has a security team responsible for this? If they have, they should be thrilled to hear this explanation and move forward with the most secure option. Otherwise, no one will care about the additional security and will be annoyed by your proposal to make it more difficult to manage. In this case, the first option is better.<\/p>\n<p>Setting the permissions use the traditional <strong>RBAC<\/strong> procedure, defining roles for identities on the correct object.<\/p>\n<h3>Storage Accounts<\/h3>\n<p>Storage Accounts have many different roles available because they offer different services: Blob, File, Queue and Table. In this way, you have roles intended to manage the storage account and roles intended to manage the data inside the storage account.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1242\" height=\"517\" class=\"wp-image-95242\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2023\/01\/word-image-16.png\" \/><\/p>\n<hr \/>\n<p>Storage accounts brings the same dilemma than the Service Bus: You can control the permissions in a granular way, giving the functions only the permissions needed, or you can give all the permissions to a single identity and set it on the functions. The granular way is always technically better for security, but it always depends if the company is willing to manage it correctly.<\/p>\n<p>The granularity in the storage account can be controlled not only by service (blob, queue, table and files), but by each element on the services. For example, you can set RBAC permission on the level of reach blob container.<\/p>\n<h3>Key Vault<\/h3>\n<p>Key Vaults can use RBAC as permission control method, but the most common method for permission control are the access policies. On the <em>Access configuration<\/em> tab in a Key Vault, you can choose rather to use RBAC or access policies to control the permissions.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"900\" height=\"417\" class=\"wp-image-95243\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2023\/01\/word-image-17.png\" \/><\/p>\n<hr \/>\n<p>Let\u2019s focus on the access policies option. You can create access policies giving permissions to access the Keys, Secrets and Certificates.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"823\" height=\"588\" class=\"wp-image-95244\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2023\/01\/word-image-18.png\" \/><\/p>\n<hr \/>\n<p>Once again, you face the granularity problem: If function A needs access to Secrets and function B needs access to Certificates, will you use a single identity with access to certificates and secrets, or would you use two identities, one with access to secrets and the other with access to certificates?<\/p>\n<p>Key Vault granularity goes further: The access control is made by type of object: Key, Secrets or certificates. Once the permission is given, the function will have access to all secrets, or all keys or all certificates. What if the function needs access only to some keys, but not to others?<\/p>\n<p>The solution is to use multiple key vaults, organizing the objects according the app which will access them. Only by doing so you can ensure each function will have access only to the information the function needs to use, and not to information related to other functions.<\/p>\n<h3>SQL Databases<\/h3>\n<p>The possibilities in relation to <strong>SQL Databases<\/strong> are wider. Some microservices implementation types would build one database for each microservice, isolating the data.<\/p>\n<p>Others would implement a single database, and that&#8217;s when the same security granularity problem comes into focus: Would you use one single identity with read and write permission? Different identities for read and write? Different identities for each database schema? The same kind of considerations as all other resources. There is no right and wrong answer. There is the safer and less safe. Less safe doesn\u2019t mean wrong. It does however mean a correct choice between risk and amount of management work is needed. The granularity choice is a complex one to be done by a skilled security team. The developer work is to introduce the best options when they are not yet being used.<\/p>\n<p><strong>Important Secret:<\/strong> The usual library to access <strong>SQL Server<\/strong>, <strong>System.Data.SqlClient<\/strong>, doesn&#8217;t support authentication with managed identities. You need to use a different library, <strong>Microsoft.Data.SqlClient.<\/strong> Luckily, the code is the same, the only change I identified was the support to managed identities authentication.<\/p>\n<p>The permissions are set using <strong>TSQL<\/strong> and the security rules specific to <strong>SQL Server<\/strong>, they are not set using <strong>RBAC<\/strong>. You can find an example below:<\/p>\n<pre class=\"lang:tsql theme:ssms2012-simple-talk\">create user [MyFunctionApp] from external provider\r\nalter role db_datareader add member [MyFunctionApp]<\/pre>\n<p><strong>Important but out of scope:<\/strong> You also need to deal with SQL Firewall, but this is out of the scope of this blog. You can take a look on the vide on <a href=\"https:\/\/www.youtube.com\/watch?v=RKZy5MkqFDQ&amp;list=PLNbt9tnNIlQ5pVwZFRVpoBG8uQTs8aIcz&amp;index=26\">https:\/\/www.youtube.com\/watch?v=RKZy5MkqFDQ&amp;list=PLNbt9tnNIlQ5pVwZFRVpoBG8uQTs8aIcz&amp;index=26<\/a> . The same principles of Service Connection and Private Endpoints also applies to Key Vaults, Storage Accounts and Service Bus.<\/p>\n<h2>The secrets of User Assigned Managed Identity<\/h2>\n<p>We would expect that <strong>User Assigned Managed Identity<\/strong> would just work, exactly as <strong>System Assigned Managed Identity<\/strong>. Unfortunately, that&#8217;s not so simple. There are many secrets to make <strong>User Assigned Managed Identity<\/strong> work. These secrets are not well documented and are different for each service.<\/p>\n<h3>Service Bus<\/h3>\n<p>In order to work with Service Bus, a User Assigned Managed Identity requires two configuration variables to be created: <strong>Azure_Client_ID<\/strong> and <strong>AZURE_TENANT_ID<\/strong>.<\/p>\n<p>The first contains the Client Id generated to identify the Managed Identity, the second is the tenant id of the managed identity.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1454\" height=\"405\" class=\"wp-image-95245\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2023\/01\/word-image-19.png\" \/><\/p>\n<hr \/>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1029\" height=\"475\" class=\"wp-image-95246\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2023\/01\/word-image-20.png\" \/><\/p>\n<hr \/>\n<p>&nbsp;<\/p>\n<p>Without these variables you will get an error message inside <strong>Application Insights<\/strong> which will be similar to this:<\/p>\n<p><em>&#8220;Azure.Identity.CredentialUnavailableException: EnvironmentCredential authentication unavailable. Environment variables are not fully configured. See the troubleshooting guide for more information. https:\/\/aka.ms\/azsdk\/net\/identity\/environmentcredential\/troubleshoot&#8221;<\/em><\/p>\n<p>The documentation doesn&#8217;t explain much, especially because we were expecting it to work out of the box, but these variables are needed. Create the variables and it will work.<\/p>\n<h3>Key Vault<\/h3>\n<p>While the <strong>System Assigned Managed Identity<\/strong> simply works, a <strong>User Assigned Managed Identity<\/strong> requires a special property in the Function App object. The property is called <em>keyVaultReferenceIdentity <\/em>and needs to contain the object Id of the Managed Identity.<\/p>\n<p>It would be simple if we could set this property on the UI, but this property isn&#8217;t available even on <strong>Azure CLI<\/strong>. We need to make a <strong>REST PATCH<\/strong> call to Azure API to set this property.<\/p>\n<p>The code below is built to be called in BASH, you can use Cloud Shell for this:<\/p>\n<pre class=\"lang:ps theme:powershell-ise\">appResourceId=<strong>$(<\/strong>az webapp show -g MyResourceGroup -n MyFunctionApp --query id -o tsv<strong>)<\/strong>\r\naz rest --method PATCH --uri \"${appResourceId}?api-version=2021-01-01\" --body \"{'properties':{'keyVaultReferenceIdentity':'\/subscriptions\/bcae138f-2b24-4931-b715-4aacd2463ef0\/resourcegroups\/MyResourceGroup\/providers\/Microsoft.ManagedIdentity\/userAssignedIdentities\/functionIdentity'}}\"<\/pre>\n<p>The first statement retrieves the app resource id, while the second completes the <strong>PATCH<\/strong> call to set the property.<\/p>\n<p>If you don&#8217;t set this property, the Function App will use the <strong>System Assigned Managed Identity<\/strong> or it will complain the identity is not enabled.<\/p>\n<h3>It&#8217;s not only for Function Apps<\/h3>\n<p>App Services, Virtual Machines, Container Apps or AKS, all kind of apps running on Azure can receive a managed identity and identify themselves to other services using this managed identity. It&#8217;s possible that each specific combination has its own tricks to work, such as the two I explained above.<\/p>\n<p>This increases the entire security of the entire environment.<\/p>\n<h2>The corporate problems: Spreading the correct solution<\/h2>\n<p>Among corporations, we always face many challenges to implement mentality-changing solutions. The users spent too many years using passwords, keys and secrets and sometimes it may be challenging to explain why using identities is better.<\/p>\n<p>Usually, you will face outdated standards and \u201cwe always did like this\u201d approaches. My suggestion is to follow the guidance of the corporation you work for, but not accept it quietly, look for openings to improve it. Let\u2019s analyze some options.<\/p>\n<h3>Expose problems with existing patterns<\/h3>\n<p>Sometimes, corporations create patterns for software development and these patterns live beyond their creator. The spread of such patterns create repetition and over time usually lacks a check if they are still the correct option.<\/p>\n<p>The solution is to find the correct person open to hear about how it really works and analyze the best way to implement it. When attempting to change any kind of security practices, you should consider socializing the solution with people on the security team.<\/p>\n<h3>Introduce the Idea of Layered Security<\/h3>\n<p><a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/security\/fundamentals\/overview#layered-security-architecture\">Layered Security<\/a> is a security approach to protect your applications from attack. The core idea is to protect every layer of your application and not only the entry point.<\/p>\n<p>Companies not familiar with this concept may see this as additional work. They may think it\u2019s enough to have a firewall and may consider not important to protect the access from one internal resource to another. For these companies, a mind changing may be needed, introducing the importance of Layered Security.<\/p>\n<p>The concept of Layered Security changes this. The point is: If a hacker manages to cross your firewall, or find another entry point, they should face more security restrictions. If you don\u2019t use the Layered Security approach and a hacker work around your entry point, they will be in, with access to all your information.<\/p>\n<p>It\u2019s the role of a skilled security professional to define the security guidelines to be followed by the company. But when the best security approaches are not in place, is the role of the developer to talk to these security professionals to highlight what could be better. Usually, they should like very much to know about additional security configuration they have available for the security guidelines.<\/p>\n<h3>Spread the knowledge among the team<\/h3>\n<p>It&#8217;s very common to work with development teams with very uneven knowledge about Function Apps and really much of the cloud functionality available. It can be useful for teams to organize knowledge sharing sessions to increase the knowledge of the team, establishing higher levels of software development standards.<\/p>\n<p>The most secure method to authenticate functions and the methods to choose between User or System assigned managed identity is a great subject for a knowledge sharing session, especially since the answer requires knowledge of the exact problems you are attempting to solve.<\/p>\n<h3>Work around permission issues<\/h3>\n<p>The work to manage <a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/role-based-access-control\/overview\"><strong>RBAC<\/strong> (Role Based Access Control)<\/a> permissions require a higher-level permission than contributor. In order to manage these permissions, you need to have <strong>User Access Administrator<\/strong> permission.<\/p>\n<p>Security and Cloud teams will typically have some resistance to provide these permissions and without understanding their purpose, they are right. The only way to allow you to work without providing these permissions is to provide you with a sandbox to work, where you have these permissions, and make all the deployment using DevOps pipelines, ensuring the correct configuration in UAT and Production environments.<\/p>\n<h2>Conclusion<\/h2>\n<p>Ensuring the best security possible is important and usually a forgotten subject. Many developers think &#8220;if it works, it&#8217;s fine&#8221;, but there are many ways that a working application may be a high risk for security.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Let&#8217;s talk about authentication between Azure Functions and resources used by Azure Functions and conclude with many poorly documented secrets about how to use User Assigned Managed Identity.\u00a0When we build Azure functions, they usually need to authenticate against other Azure resources: Azure SQL Database, Storage Accounts, Service Bus and many more. Each of these services&#8230;&hellip;<\/p>\n","protected":false},"author":50808,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[137091,53],"tags":[],"coauthors":[6810],"class_list":["post-95225","post","type-post","status-publish","format-standard","hentry","category-azure","category-featured"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/95225","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/50808"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=95225"}],"version-history":[{"count":12,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/95225\/revisions"}],"predecessor-version":[{"id":95256,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/95225\/revisions\/95256"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=95225"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=95225"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=95225"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=95225"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}