Skip to content

Commit 1b98757

Browse files
author
Christy Henriksson
authored
Merge pull request #6333 from NuGet/dev
[ReleasePrep][2018.08.20]RI of dev into master
2 parents b634f27 + 88b36b0 commit 1b98757

File tree

142 files changed

+4063
-1286
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+4063
-1286
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
[NuGet Gallery](http://nuget.org/) — Where packages are found
1+
[NuGet Gallery](http://nuget.org/) — Where packages are found
22
=======================================================================
33

4-
[![Build status](https://ci.appveyor.com/api/projects/status/6ob8lbutfecvi5n3/branch/master?svg=true)](https://ci.appveyor.com/project/NuGetteam/nugetgallery/branch/master)
5-
64
This is an implementation of the NuGet Gallery and API. This serves as the back-end and community
75
website for the NuGet client. For information about the NuGet project, visit the [Home repository](https://github.com/nuget/home).
86

@@ -49,6 +47,10 @@ You can undo this with this command:
4947
5048
This should help prevent unwanted file commits.
5149
50+
## Deploy
51+
52+
You will find instructions on how to deploy the Gallery to Azure [here](https://github.com/NuGet/NuGetGallery/blob/master/docs/Deploying/README.md).
53+
5254
## Contribute
5355
If you find a bug with the gallery, please visit the [Issue tracker](https://github.com/NuGet/NuGetGallery/issues) and
5456
create an issue. If you're feeling generous, please search to see if the issue is already logged before creating a

appveyor.yml

Lines changed: 0 additions & 8 deletions
This file was deleted.

docs/APIv3.md

Lines changed: 0 additions & 12 deletions
This file was deleted.

docs/Deploying/CloudServices/README.md

Lines changed: 0 additions & 41 deletions
This file was deleted.

docs/Deploying/README.md

Lines changed: 25 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,119 +1,61 @@
11
# Deploying the NuGet Gallery
22

3-
To run the NuGet Gallery you need to provision the following common resources:
3+
To run the NuGet Gallery in Azure you need to provision the following resources:
44

5-
1. An SQL Database to hold the package metadata.
5+
1. A SQL Database to hold the package metadata.
66
2. A location in which to store package files. The Gallery supports two at the moment: Local File System and Azure Storage Account.
77
3. A Web Frontend to host the Gallery.
8-
4. (Optional) A Worker Backend to perform offline processing tasks.
98

109
## Deploying to Azure
1110

12-
We suggest using Windows Azure for hosting the gallery, as that is the environment used by http://www.nuget.org itself. When doing so, we suggest using Azure SQL Databases (formerly SQL Azure) for the database and Azure Storage Accounts to store package files.
11+
We suggest using Windows Azure for hosting the gallery, as that is the environment used by http://www.nuget.org itself. When doing so, we suggest using Azure SQL Databases for the database and Azure Storage Accounts to store package files.
1312

14-
We support two profiles of Azure deployment: [Azure Websites](Websites) and [Azure Cloud Services](CloudServices). Before using those guides, however, you need to ensure you provisiong the supporting resources (Database, Storage, etc.).
13+
This guide will instruct you on hosting the Gallery to an Azure App Service. We will start with provisiong the supporting resources (Database, Storage, etc.).
1514

1615
## Provisioning for Azure
1716

1817
### Provisioning a Database
1918

20-
We recommend provisioning a dedicated Azure SQL Databases Server for the Gallery. If you are going to use our backend worker to generate statistics reports from data in a NuGet Warehouse, we recommend provisioning a separate Server for that database in production (the Warehouse may be co-located with the Gallery database if necessary though, and we do co-locate them in our non-production environments).
19+
We recommend provisioning a dedicated Azure SQL Databases Server for the Gallery.
2120

22-
So, first create a database:
23-
24-
![Creating the Database](images/01-CreateDB.png)
25-
26-
Next, we need to create a user for the site to use. Open the **server** in the Azure Portal and click on the URL under `Manage URL`
27-
28-
![Manage URL](images/02-ManageUrl.png)
29-
30-
Type "master" in the database field and log in using the SA password for the server (which you should have copied down when you created the server ;)).
31-
32-
If you receive an error about firewall rules, go to the SQL Server entry in the Azure Portal, click the Configure tab and add your current client IP address to the list of allowed IP addresses (don't forget to click Save!). While here, double check that Allow Windows Azure Services is set to "YES".
33-
34-
Once logged in to the SQL management portal, create a new query and type the following (of course, replace 'some password here' with an actual, secure, password :)):
35-
36-
```SQL
37-
CREATE LOGIN [nuget-site] WITH PASSWORD='some password here'
38-
```
39-
40-
We use "nuget-site" as the name, but feel free to use any user name you want.
41-
42-
Now, log out and log in again, but this time, specify the name of the gallery database in the "Database" field (i.e. NuGetGallery). Then, create a new query and run these scripts (one at a time):
43-
44-
```SQL
45-
CREATE USER [nuget-site] FROM LOGIN [nuget-site]
21+
Follow the instrctions [here](https://docs.microsoft.com/en-us/azure/sql-database/sql-database-get-started-portal) to create an Azure SQL DB.
22+
Copy the connection string from the portal. It should look something like:
4623
```
47-
48-
```SQL
49-
EXEC sp_addrolemember 'db_owner', 'nuget-site';
24+
Server=[servername].database.windows.net;Database=NuGetGallery;User ID=[username];Password=[password];Trusted_Connection=False;Encrypt=True
5025
```
5126

52-
If you used a different site username, use it in place of 'nuget-site' in the scripts.
27+
Now, it's time to update your new DB with the Gallery SQL schema.
5328

54-
Now, log off the management portal and switch to VS. Open the NuGetGallery solution and expand the "Package Manager Console" tool window:
29+
1. Open the NuGetGallery solution in Visual Studio.
5530

56-
![Package Manager Console](images/03-PackageManagerConsole.png)
57-
58-
Craft your connection string using notepad or some other text editor. You want it to take the following form:
31+
2. Open the [web.config](https://github.com/NuGet/NuGetGallery/blob/master/src/NuGetGallery/Web.config#L183) and replace the Gallery.SqlServer connection string with this value.
5932

60-
```
61-
Server=[servername].database.windows.net;Database=NuGetGallery;User ID=sa@[servername];Password=[sapassword];Trusted_Connection=False;Encrypt=True
62-
```
33+
3. Expand the "Package Manager Console" tool window:
6334

64-
Replacing '[servername]', 'sa' and '[sapassword]' with the name of your Azure SQL Server, the SA user name and the SA password respectively. Keep this handy for the next step but make sure you store it securely, as this contains a password which grants **full admin access** to your database.
35+
![Package Manager Console](images/03-PackageManagerConsole.png)
6536

66-
In the Package Manager console, type the following command
37+
4. In the Package Manager console, type the following command:
6738

6839
```PowerShell
69-
Update-Database -ConnectionString "[ConnectionString]" -ConnectionProviderName System.Data.SqlClient
40+
Update-Database -ConfigurationTypeName MigrationsConfiguration
7041
```
7142

72-
Replacing '[ConnectionString]' with the connection string you just crafted. The command should succeed and you should have a fully prepared database!
73-
7443
### Provisioning Storage Accounts
75-
We also recommend the following Storage Accounts for each environment you intend to deploy (i.e. development, test, production, etc):
76-
77-
1. A Primary Storage account to hold package files and other supporting content.
78-
2. A Backup Storage account to hold package and database backups in case the primary storage account is lost.
79-
3. A Diagnostics Storage account to hold logs and other data. In non-production environments, we recommend using the Primary storage account to hold this data. In production, however, your traffic may be large enough that you may wish to move diagnostics data (Web Server logs, etc.) to a separate storage account
80-
81-
### Gathering configuration
82-
Now that you've got the database ready, all the resources are ready for you to deploy the site. First, though, we need to configure the Website so that it will be able to talk to the database and storage when it is deployed. To do this, go to the website in the Azure Portal and select the Configure tab.
83-
84-
Craft a connection string using the 'nuget-site' user you created earlier (by taking the connection string above and replacing sa and '[sapassword]' with the username/password for that user). Then, in the portal, add the database connection string like so:
85-
86-
![Adding Connection String](images/04-ConnectionString.png)
87-
88-
Then, go to the storage account you created in the portal and select "Manage Keys". Use the name and primary key on that page to build a connection string like this:
8944

45+
Follow the instruction [here](https://docs.microsoft.com/en-us/azure/storage/common/storage-quickstart-create-account?tabs=portal) to create an Azure storage account.
46+
Copy the connection string from the portal. It should like something like:
9047
```
9148
DefaultEndpointsProtocol=https;AccountName=[account name];AccountKey=[primary key];
9249
```
93-
94-
Now that you have your dependent resources and their configuration, move on to...
50+
To configure Gallery to use your new storage account:
51+
1. Open the [web.config](https://github.com/NuGet/NuGetGallery/blob/master/src/NuGetGallery/Web.config#L27)
52+
2. Set Gallery.StorageType to 'AzureStorage'
53+
3. Replace all settings starting with 'Gallery.AzureStorage.' with your connection string.
9554

9655
## Deploying the Frontend/Backend
97-
Once you've provisioned these resources, continue to the guide for deploying to the profile of your choice:
9856

99-
1. [Azure Cloud Services](CloudServices/README.md) - Recommended for extremely high availability services
100-
2. [Azure Websites](Websites/README.md) - Recommended for simple deployment scenarios
101-
102-
We do not currently recommend Azure Websites for extremely high availability deployments of the Gallery. Other Azure features for traffic management, such as Azure Traffic Manager, do not support Azure Websites at this time. Also, Azure Websites does not provide the Production/Staging VIP Swap mechanism used in Cloud Services to allow for staging of production changes.
103-
104-
## Making an Admin
105-
Once you've got your gallery deployed, you probably want an admin user. That's pretty easy to do. First, register your admin user through the site. Then log in to the database using the Azure SQL Management Portal and the 'nuget-site' user (as we did above). Then run this SQL:
106-
107-
```SQL
108-
INSERT INTO Roles(Name) VALUES('Admins')
109-
110-
DECLARE @adminId int
111-
SELECT @adminId = [Key] FROM Roles WHERE Name = 'Admins'
112-
113-
DECLARE @userId int
114-
SELECT @userId = [Key] FROM Users where Username = 'username'
115-
116-
INSERT INTO UserRoles(UserKey, RoleKey) VALUES(@userId, @adminId)
117-
```
57+
You are almost done! Here are additional configurations in web.config:
58+
1. Gallery.SiteRoot - set with the URL of your Gallery website. For example: _https://mygallery.azurewebsites.net_
59+
2. Gallery.SmtpUri (optional)- set SMTP credentials if you would like to receive e-mails from the service.
11860

119-
Replacing 'username' with the name of the user you just created. Now log out and back in with that user and you should see the Admin tab! **NOTE** The name of the role is important, it is "Admins" (plural!).
61+
Now you are ready to publish the Gallery to your own Azure app service. To do this through Visual Studio follow the instructions [here](https://docs.microsoft.com/en-us/visualstudio/deployment/quickstart-deploy-to-azure).

docs/Deploying/Websites/README.md

Lines changed: 0 additions & 51 deletions
This file was deleted.
-14.1 KB
Binary file not shown.
-2.63 KB
Binary file not shown.
-7.12 KB
Binary file not shown.

0 commit comments

Comments
 (0)