Azure File Storage Access for Windows Service Accounts - azure

I have a VM running Services under local service accounts that are looking for mapped drives OR UNC paths. I can map a drive (using the powershell fragments from the portal) -- but this mapping only applies to ME, not the service accounts.
I created Azure AD Domain Services
I created a user with AD rights.
My VM has a system-assigned identity.
I created a storage account.
The system-assigned identity is assigned to the storage account as Contributor.
I am expecting to map a UNC without providing credentials -- mapping UNC without providing credentials does not work.
I tried joining the VM to the AD -- mapping UNC without provding credentials does not work.
What am I doing wrong ?

Azure Files AAD Domain Service (AAD DS) Authentication doesn't work for system-assigned identities as these identities are only presented in AAD not AAD DS. Given that AAD DS cannot authenticate system-assigned identities, it will not be able to issue valid Kerberos token for connection to Azure Files. In this case, you can use the AAD user or group identity to connect to Azure Files over SMB.

Related

How to fetch token for azure storage account access via azure active directory using service principal or oauth2?

I am looking for examples to fetch access token for azure storage account access via azure active directory with service principal in python
It seems like https://github.com/AzureAD/azure-activedirectory-library-for-python/blob/dev/sample/client_credentials_sample.py doesn't support service principal access
are there other ways in fetching token via service principal?
• Yes, you can surely fetch an access token for an Azure storage account via Azure Active Directory using a service principal, i.e., an app registration by following the steps below as given in the below documentation link: -
https://learn.microsoft.com/en-us/azure/developer/python/sdk/authentication-azure-hosted-apps?tabs=azure-portal%2Cazure-app-service
As per the above documentation, you will have to host your python application code in a web app service and create a system assigned managed identity for it. Once created, then an application will be created in Azure AD with the same ‘Object ID’ as shown in the managed identity section of the web app service. Before moving onto this application created in Azure AD, assign the required roles to this system assigned managed identity through the ‘IAM’ tab. So, in your case, you should assign the role of ‘Storage Account Contributor’ to the ‘System-assigned managed identity’ created for the web app service.
• Once, the role has been assigned, then go to the ‘Enterprise application’ and search for the ‘Object ID’ of the managed identity, you will encounter an application with the name of the web app service, in that, go to ‘Permissions’ under ‘Security’ tab and assign the required permissions and admin consent required to the application. The permissions shown are those that are allowed under the scope of ‘Storage Account Contributor’ and similarly, you must assign permissions from it to the app/service principal. Then ensure that you are correctly calling the environment variables of this application created in Azure AD regarding the managed identity and implement the ‘DefaultAzureCredential’ from the ‘azure.identity’ module. For this purpose, kindly refer to the below subsection of the above documentation: -
https://learn.microsoft.com/en-us/azure/developer/python/sdk/authentication-azure-hosted-apps?tabs=azure-portal%2Cazure-app-service#3---implement-defaultazurecredential-in-your-application
In this way, you can fetch an access token for the Azure storage account via Azure Active Directory using a service principal.

Cannot access storage table with the azure application which is having owner access

We earlier used sas token to access the storage account.Now the requirment is to not to use it. Is it possible for an azure app to access the storage account if it has owner access. I tried using it . But getting this error.
message": "The specified resource does not exist
the url we are using is
`https://${tableService.storageAccountName}.table.core.windows.net/tablename
Simply pointing to a storage account, without any form of credentials, will not work for a private storage account or container.
There are a couple of options you have to provide credentials to connect to a storage account, like using the connection strings containing the access keys or using Managed Identities for Azure resources.
Managed identities provide an identity for applications to use when connecting to resources that support Azure Active Directory (Azure AD) authentication. Applications may use the managed identity to obtain Azure AD tokens.
Here are some of the benefits of using managed identities:
You don't need to manage credentials. Credentials aren’t even accessible to you.
You can use managed identities to authenticate to any resource that supports Azure AD authentication, including your own applications.
Managed identities can be used without any additional cost.
Because of these benefits and the ease of use I would suggest you Authorize access to blob data with managed identities for Azure resources.
Azure Blob Storage supports Azure Active Directory (Azure AD) authentication with managed identities for Azure resources. Managed identities for Azure resources can authorize access to blob data using Azure AD credentials from applications running in Azure virtual machines (VMs), function apps, virtual machine scale sets, and other services. By using managed identities for Azure resources together with Azure AD authentication, you can avoid storing credentials with your applications that run in the cloud.
Assign an RBAC role to a managed identity
When an Azure AD security principal attempts to access data in an Azure Storage account, that security principal must have permissions to the data resource. Whether the security principal is a managed identity in Azure or an Azure AD user account running code in the development environment, the security principal must be assigned an Azure role that grants access to data in Azure Storage.

How can I manage Azure AD B2C with a service principal from the main directory

We are running Azure AD B2C to authenticate users in our application. We also managed to codify almost everything with Terraform and are pretty happy with it. Now we are attempting to move these manifests under Azure Devops Pipelines and are stuck with access problems.
Azure Pipelines use a dedicated service principal in the main (non B2C) Active Directory to perform its operations. We granted this SP enough permissions within the target subscription to handle Terraform resources. But I cannot find any way to grant this SP any permissions on the B2C directory. I can invite users from the primary directory to the B2C, and it works fine, but SP is an application, not a user.
Is there any way to "invite" an application from the primary directory into the B2C directory?
Is there any way to "invite" an application from the primary directory
into the B2C directory?
If your app registration support account types is Accounts in any organizational directory (Any Azure AD directory - Multitenant), you would be able to add the same service principal in your Azure AD B2C Tenant
As you want to use the service principal in Azure Pipelines to handle Terraform resources, it is suggested to use separate service principals for Azure AD and Azure AD B2C as Authentication will be different for the service principal with multi-tenant account support type

While using Azure Managed service Identity, AKS, AAD and Key vault. Do all these resources need to be in the same subscription/Resource group or VNET

Basically I have a setup where I have
Hub-Spoke subscription and vnet topology in azure.
AAD for internal users and developer access and b2c for external
users.
AAD and Keyvault are in HUB subscription/VNET.
APIs which are deployed in Azure AKS clusters are in the spoke subscription.
Also have API Management fronting the APIs which is in the same
subscription and VNET as the AKS/APIs so in the Spoke subscription
Given the setup above, I have these questions
Do all the APIs, API management, Keyvault and Azure AD need to be
tied to the same subscription or can I have Keyvault in my hub
subcription and other services in different subscriptions.
Do we register each API as an app in the same AAD as
KEYVAULT or can we just register the API management and use API
management to get the secrets.
Can we use managed service identity, even if the components are in
different subscriptions but registered with the same Azure AD
Authentication in Azure is done at a tenant level, so presuming you're not using the advanced services for Key Vault (ARM access, VM encryption etc) you can have your Key Vault in one subscription and access that from MSI in a difference subscription - as long as you grant that MSI user permissions to the key vault.
As long as you grant permissions to the resource, AAD has very little awareness of subscriptions (subscriptions are basically one big resource that you can grant privileges to)
Edited to clarify advanced access policies
There are three advanced access policies for key vault.
enabledForDeployment
enabledForDiskEncryption
enabledForTemplateDeployment
the enabledForTemplateDeployment policy only applies if you are reading a secret from an ARM template deployment. i.e. if you are passing a VM password directly from Key vault.
For your situation, if this is a requirement, then you could simply have those being placed in a different key vault located in the same subscription.

Can I share the same KeyVault between Azure B2C, and Azure B2B (AAD)?

A KeyVault seems to be tightly coupled to a single AAD instance
What guidance should I follow when I want to support Azure AD (B2C) and B2B / Work users?
I'm currently exploring this solution to help manage the independent sign in flows.
According to the docs for Set-AzureRmKeyVaultAccessPolicy PowerShell cmdlet that gives access to an app or a user to secrets in the Key Vault:
The following directories must all be the same Azure directory:
-- The default directory of the Azure subscription in which the key vault resides.
-- The Azure directory that contains the user or application group that you are granting permissions to.
So the Key Vault will be in a subscription and that subscription is attached to a single Azure AD. Any application that is given access must be from that directory.

Resources