0

I have trying to create a web app through fluent Azure Management Library.

I am currently on DreamSpark Subscription.

Here is my program.cs

static void Main(string[] args)
        {
            // Set some variables...
            string rgName = "numbers1102rg";
            string appName = SdkContext.RandomResourceName("WebApp", 20);

            // Authenticate
            var credentials = SdkContext.AzureCredentialsFactory
                .FromFile(Environment.GetEnvironmentVariable("AZURE_AUTH_LOCATION"));

            var azure = Azure
                .Configure()
                .WithLogLevel(HttpLoggingDelegatingHandler.Level.Basic)
                .Authenticate(credentials)
                .WithDefaultSubscription();

            // Create the web app
            Console.WriteLine("Creating Web App...");
            var app = azure.WebApps.Define(appName)
                .WithRegion(Region.USEast)
                .WithNewResourceGroup(rgName)
                .WithNewFreeAppServicePlan()
                .DefineSourceControl()
                .WithPublicGitRepository("https://github.com/Azure-Samples/app-service-web-dotnet-get-started")
                .WithBranch("master")
                .Attach()
                .Create();
            Console.WriteLine("Your web app is live at: https://{0}", app.HostNames.First());

            // Wait for the user
            Console.WriteLine("Press enter to continue...");
            Console.ReadLine();
        }

I have also, done the azureauth.properties setup.

Here is the error it throws while creating: enter image description here

I have also performed steps to be a contributor from here:

https://docs.microsoft.com/en-us/dotnet/azure/dotnet-sdk-azure-get-started?view=azure-dotnet

And the app is a contributor to that resource: enter image description here

4

1 回答 1

0

您收到此错误是因为为其获取访问令牌的用户无权在您正在使用的资源组中创建资源(在您的情况下为 WebApp)。

要修复此错误,请为Contributor您正在使用的资源组中的该用户分配一个角色(例如 a )。

请参阅此链接,了解如何使用 Azure 门户为用户分配角色:https ://docs.microsoft.com/en-us/azure/active-directory/role-based-access-control-configure 。

于 2017-06-06T07:39:30.487 回答