MicrosoftDocs / azure-docs

Open source documentation of Microsoft Azure
https://docs.microsoft.com/azure
Creative Commons Attribution 4.0 International
10.31k stars 21.5k forks source link

.Net Framework Web application using managed identity? #52131

Closed bebemau closed 4 years ago

bebemau commented 4 years ago

Any sample application for .Net Framework web application? I have been successful with integrating App Configuration Store with Core web application and .net Framework core but cant get a .net framework web application to work. I kept getting this error: Method not found: 'Void Azure.Data.AppConfiguration.SettingSelector.set_AsOf(System.Nullable`1<System.DateTimeOffset>)'.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

kobulloc-MSFT commented 4 years ago

@bebemau Thank you for the feedback! We are investigating this and will get back to you shortly.

kobulloc-MSFT commented 4 years ago

@bebemau I'll pass that request to the document author.

For .NET Framework console apps, I went through the documentation and it may be helpful to see what a finished App.config looks like.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <configSections>
        <section name="configBuilders" type="System.Configuration.ConfigurationBuildersSection, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" restartOnExternalChanges="false" requirePermission="false" />
    </configSections>
    <configBuilders>
        <builders>
        <add name="AzureAppConfig" endpoint="[Config_Store_Endpoint_Url]" type="Microsoft.Configuration.ConfigurationBuilders.AzureAppConfigurationBuilder, Microsoft.Configuration.ConfigurationBuilders.AzureAppConfiguration, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
        <!--  This is included by default, and we're going to use "Environment" from the quickstart below.
        <add name="Environment" type="Microsoft.Configuration.ConfigurationBuilders.EnvironmentConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.Environment, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
        -->
        <add name="MyConfigStore" mode="Greedy" connectionString="${ConnectionString}" type="Microsoft.Configuration.ConfigurationBuilders.AzureAppConfigurationBuilder, Microsoft.Configuration.ConfigurationBuilders.AzureAppConfiguration" />
        <add name="Environment" mode="Greedy" type="Microsoft.Configuration.ConfigurationBuilders.EnvironmentConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.Environment" />
        </builders>
    </configBuilders>
    <appSettings configBuilders="Environment,MyConfigStore">
      <add key="AppName" value="Console App Demo" />
      <add key="ConnectionString" value ="Endpoint=https://appconfig-dotnet.azconfig.io;Id=1Ab2-c3-d4:e5fGhi67jk8LmNOPQ9Rs;Secret=ABcd+EF12+Ghijkl3MnOpQrS4tU5Vw6xyZa7bcCeFG8=" />
    </appSettings>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
    </startup>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.1.1" newVersion="4.0.1.1" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Azure.Core" publicKeyToken="92742159e12e44c8" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.0.2.0" newVersion="1.0.2.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

Program.cs is very straight forward:

namespace AppConfigDotNET
{
    class Program
    {
        static void Main(string[] args)
        {
            string message = System.Configuration.ConfigurationManager.AppSettings["TestApp:Settings:Message"];

            Console.WriteLine(message);
        }
    }
}

Then you should get something like this:

image

lisaguthrie commented 4 years ago

There's a new ASP.NET sample here: https://github.com/Azure/AppConfiguration/tree/master/examples/DotNetFramework/WebDemo

Also working on a tutorial on our docs site.

bebemau commented 4 years ago

Thank you very much for the update and the sample, i will take a look at it.

The issue i have is i am not able to use managed identity with a web application. Connection string works but looks like connection string will not be supported in newer version and we do prefer using managed identity.

On Tue, Apr 14, 2020 at 11:18 PM kobulloc-MSFT notifications@github.com wrote:

@bebemau https://github.com/bebemau I'll pass that request to the document author.

For .NET Framework console apps, I went through the documentation https://docs.microsoft.com/en-us/azure/azure-app-configuration/quickstart-dotnet-app#connect-to-an-app-configuration-storeand it may be helpful to see what a finished App.config looks like.

<?xml version="1.0" encoding="utf-8"?>

Program.cs is very straight forward:

namespace AppConfigDotNET { class Program { static void Main(string[] args) { string message = System.Configuration.ConfigurationManager.AppSettings["TestApp:Settings:Message"];

        Console.WriteLine(message);
    }
}

}

Then you should get something like this:

[image: image] https://user-images.githubusercontent.com/37556655/79304329-ee3e8600-7ea5-11ea-974c-355581c446cf.png

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/MicrosoftDocs/azure-docs/issues/52131#issuecomment-613839555, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA2DWI5CDNTPLHABOGDGENTRMVGSTANCNFSM4MFDBOAA .

lisaguthrie commented 4 years ago

Hi @bebemau - sorry for the delayed response. There is a sample for using managed identity with .NET Framework in this article. Let us know if you're having any other problems.

please-close